在数据库xaml.cs中显示数据网格中的数据 [英] Display data in datagrid from database xaml.cs
本文介绍了在数据库xaml.cs中显示数据网格中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码没有在数据网格中显示数据
My code is not showing data in datagrid
SqlDataAdapter da = new SqlDataAdapter("Select Companyid from Accounts where Companyid= 1 ", con);
DataSet ds = new DataSet();
da.Fill(ds);
DataGrid.ItemsSource = ds.Tables[0].ToString();
推荐答案
试试这篇文章他们会帮助你。
使用DataTable:
使用SQL Server数据库的WPF DataGrid控件中的数据绑定 [ ^ ]
使用linq:
http://msdn.microsoft.com/en-us/library/ee340709.aspx [ ^ ]
Try this article they will help you.
Using DataTable:
Data binding in WPF DataGrid control using SQL Server database[^]
Using linq:
http://msdn.microsoft.com/en-us/library/ee340709.aspx[^]
SqlDataAdapter da = new SqlDataAdapter(从Company中选择Companyid = 1,con);
DataSet ds = new DataSet();
da.Fill(ds);
DataGrid.DataSource = ds.Tables [0]; //改变这样就够了
SqlDataAdapter da = new SqlDataAdapter("Select Companyid from Accounts where Companyid= 1 ", con);
DataSet ds = new DataSet();
da.Fill(ds);
DataGrid.DataSource = ds.Tables[0];//change like this its enough
这篇关于在数据库xaml.cs中显示数据网格中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文