I started developing simple application in WPF and XAML.
I want to try accessign the sql server database and display the data from stored procedure onto the UI form.
I have a table called parentProject -> idParentProject (pk), txtParentProjName varchar(max).
my SP is parentProj_sp -> select * from parentProject.
n
I want to use a dropdown list in which, If the sp returns say (3) records, then dropdownlist should have those 3 records retreived from sp.
similar manner, I have subproject -> idsubproject(pk), idParentProject , txtSubProjectName varchar(max), dateProjstart, dateprojectend.
once the parentprojectname is selected from first dropdown, then, subproject dropdown should be enabled and it should have the subprojectnames for the corresponding parent project.
my sp is subproject_sp -> SELECT dtProjectStart, dtProjectEnd FROM tblSubProject WHERE (idParentProject = #idProjectIndex).
please help me how to connect to database in C# using WPF and XAML.
Thank You,
Ramm
1) Select the technology you want to use to access the database. (Hint: It's not WPF w/XAML)
2) Read the documentation for that particular technology.
3) Use the documented behavior to create your connection and do what you need to do.
4) Profit!
Your question clearly indicates that you don't understand the technology stack you're working with. You need to return to basics and grasp what WPF, XAML, and databases are, as well as how they interact.
Try
ScottGu's great series on Linq to Sql which is probably the easiest way to get started IMHO.
http://weblogs.asp.net/scottgu/archive/2007/07/16/linq-to-sql-part-5-binding-ui-using-the-asp-linqdatasource-control.aspx
Or for more in depth study
http://msdn.microsoft.com/en-us/library/bb425822.aspx
You will want to combine two technologies. Data Acess and Data Binding.
For Data Acess use one of Ado.Net, Linq2Sql, or what the rest of your group prefers.
Related
Good morning everybody, this is the first time I write in this forum so, i'm sorry if I do some error!!!
I'm working on a project in Visual Studio where I'm connecting to an Access Database. The most important thing is that this Database is not mine and I can't modify it because it is updated daily by another automatic software.
I have to think that this database is "Read Only".
This database only has tables with primary key but there are no relation between tables.....it really looks like different Excel sheets!!!
I don't have problem to import the tables in a DatagridView of my Visual Studio project but in these tables the data are not easy to be understood for example:
there is a column named "Color" where the color are filled like number but there is not another Table who contain the color code. I know in my mind that color 1=Red, 2=Orange, 3=Brown etc.....
What I want to do?
I want that in my DataGridView won't be show the numbers but the color name so I need to modify my DataGrid source before display data.
How is did my project?
I have my DatagridView whose data source is a BindingSource that has a Dataset as DataSource. On my Load event I use the "Fill" method of my TableAdapter to display my tables data
Could someone suggest me how modify data before display them?
Thanks a lot
Giacomo
If all you are dealing with is a limited number of values in one or two fields, you could select the records using a query and obtain the color as follows:
SELECT Table1.ID, Table1.FldA, Table1.ClrFlag, IIf([clrflag]=1,"RED",IIf([clrflag]=2,"Orange",IIf([clrflag]=3,"Brown","Unknown")))
AS MyClr
FROM Table1
If there are many lookup's to do, I would create my own database with tables of code translations and join the two databases to produce my result. The following is an example of SQL pulling from two databases:
https://support.microsoft.com/en-us/help/113701/how-to-access-multiple-databases-in-an-sql-query-in-vb-3-0
I’m new to MVC and am building a project in ASP.NET MVC.
In my project I don’t want to delete any saved data from my database, but hide them from the user. I look some giving status to data, but I don’t understand. What is the explanation?
I can explain a common way to do it. This is a quick answer using SQL Server.
Please study SQL first before starting your project. Here is a good place to learn SQL.
I assume the table name is "MyItems":
Add another column to your table
Name it as IsActive (or whatever you want)
Set the data type as bit
You can set either true or false for this column
Write your SQL select query as:
Select * from MyItems where IsActive=1
This will give you all IsActive=true records.
If you want to get hidden records:
Select * from MyItems where IsActive=0
Here's the general schema for my tables(incomplete)
Employees(**EMPiD**, FirstName, Lastname, cell, name)
Trainers(**TrainerName**, Specialty)
EmployeeTrainingCompleted(**EMPID,TypeTraining,** TrainerName, Score, Comments)
Training(**TypeTraining,PositionTitle**) //this one is fishy, and likely subject to change, but irrelevent to this question
Position(**PositionTitle**,Description,StartingPay)
I am working on an Access 2010 form that will allow the user to select from a combobox the "name" field of a particular employee(which is a calculated field from fname,lname) and view all of the completed training, trainer name, comments, score, etc for that EMPID.
I have completed forms that do this for a single instance of training, but I would like for there to be one form that will dynamically display an indeterminate amount of rows for each employee(because employees have completed a different amount of training courses).
I am new to Microsoft Access and I was wondering if there is an easy way to accomplish this.
Thanks for your input.
While MySQL and Oracle are useful for the database side of things, they will be of no use for the RAD side. Access is really a RAD tool that generally, but by no means always, uses a Jet/ACE database for a back-end ( https://stackoverflow.com/tags/ms-access/info ).
To get a general idea of what you can do with Access, look at the Northwind Sample database, which you will find in New --> Sample Templates --> Northwind in your Access 2010 or if you intend to work with a web deployment, http://blogs.office.com/b/microsoft-access/archive/2010/07/19/northwind-2010-web-database-is-now-available.aspx.
Calling these "databases" is misleading, in that they include a great deal more than you will find in a database. In this case, have a look at the Order Details form under Customers & Orders.
I am not sure about the 2010 version of Northwind, but the earlier versions used to come with a warning that you should disregard any code and just use them for ideas on what you can do with MS Access. For code, consider these books MS Access 2003 - Good book on learning advanced VBA.
I am having one situation,
Book Number | Book Authors | Publications | Versions
Controls i used in above fields, label in Book No., Combo box in Book Authors, Label in Publications and Combo box in Versions.
The above is my UI, if i choose the book authors from the combo box(values in combo box are retrieving from db), the values of publications and versions should retrieve from the db based upon the item i choose from the combo box. The page should not refresh. How to write the stored procedure for this.
It seems like you really are asking the wrong question. There are a couple good answers here for how to write a select statement (via a stored procedure, or not).
However, getting the data from the database has little to do with to putting that data into the appropriate controls on your UI, and nothing to do with making sure the page does not refresh.
If you are really interested in how to how to write a stored procedure for a simple select statement, accept #MikaelEriksson's answer, but add appropriate SET statements to minimize future upgrade issues. You will also need to modify the column and table names to reflect your actual data (of course).
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE GetBooksByAuthorID
#AuthorID int
AS
BEGIN
SELECT B.BookName,
B.BookID
FROM Books as B
WHERE B.AuthorID = #AuthorID
ORDER BY B.BookName
END
GO
If you are interested in how to bind the data to your UI, and how to do it without refreshing the UI; then you need to ask a new question about that. It should be specific to your web framework. Generally speaking, if you want web UI update without refresh, you will be using some form of AJAX.
If what you're trying to do is just cascading boxes, you write a SELECT query that return the appropriate rows. This is not what a stored procedure does.
SELECT * FROM `books` WHERE `author_id` = [author_id]
Stored procedures are used to process data, not select it.
Check this Sites to Start of:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET
Calling Stored procedures in ADO.NET
The C# Station ADO.NET Tutorial
Regards
This is how you write a stored procedure that will fetch something for you. I have of course no idea what output you want and what parameters you need so ...
create procedure GetBooksByAuthorID
#AuthorID int
as
select B.BookName,
B.BookID
from Books as B
where B.AuthorID = #AuthorID
order by B.BookName
I'm using Zend Framework's Zend_Db_Table classes to fetch data from a database.
I'd like to "refine" each row I fetch from a table by adding something to it. Within a plain old SQL query I would write eg. SELECT *, dueDate<NOW() AS isOverdue. In this example, feeding an extra field to the SQL query would be possible, but sometimes it might be more suitable to do the extra stuff with PHP. Anyway, I'd use this information mainly in my views, eg. to highlight overdue items accordingly.
What would be a good place to add this isOverdue data in a ZF application?
My thoughts so far:
finding that ZF has a built-in mechanism for this (not successful so far)
subclassing Zend_Db_Table_Row
overriding _fetch() in my Zend_Db_Table class
rethinking whether this is a sane pattern at all :)
As a bonus, it would be nice that I could still use ZF to update rows. Maybe this would be (another) reason for a naming convention for custom fields?
Why reinventing the wheel? There's a built in functionality to do this:
$this->select()->from('your_table_name_here', array('*', 'dueDate<NOW() AS isOverdue'));
Simply specify what columns you need using the second parameter of from() function and it will generate the SQL that you need (by default, if you do not use a second parameter it generates "SELECT * FROM table" query).
PavelDubinin.com - Professional Web Development blog