Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,
i am trying to get the details from sql database to in my WPF application.
but tables fields are not getting in my application regrading in this code

XML
private void button1_Click(object sender, RoutedEventArgs e)
        {
            DataClasses1DataContext display = new DataClasses1DataContext();
            var q = from a in display.GetTable<EMP>()
                    select a;
            dataGrid1.ItemsSource = q;

}
is there any mistake ,is yes please any body help to me
thanks in advance........
Posted

Please check following CP Articles:

In this article you will get information about how to display data from a SQL Server database table in a WPF DataGrid control:
Data binding in WPF DataGrid control using SQL Server database[^]
DataGrid in WPF using SQL Server Compact 3.5 Sp1[^]
 
Share this answer
 
i changed in xaml code very simple............i was confused...

<dategird1 itemsource="{Binding}">

 
Share this answer
 
hi,
please use display member and value member property and databind function if it is in asp.net .

use following for window forms..
dataGrid1.DataMember="column name"; that you want to display

write this line.
If this Doesn't works then please let us know about the error as well that is coming.

Thanks.
 
Share this answer
 
v2
Comments
Unareshraju 18-May-12 8:41am    
hi preet**,
thanks for reply.........actually here
dataGrid1.(not displaying DATAMEMBER") ..only teble values are not displayed in datagrid....not showing any error.
preet88 18-May-12 13:40pm    
aah! sorry i was thinking it in a wrong way.
i think in this syntax you can also access the table
for eg from a in display.sometablename
select a;

here sometablename refers to a ienumerable class which has a same name that your table has in database and i hope that it may solve your problem i'm not sure but you can give a try

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900