【发布时间】:2012-11-18 13:17:01
【问题描述】:
我正在尝试在 C# 中显示一个 DataGrid(适用于应用程序 WindowsMobile)。我在 DataConnections 中有一个数据库(“pruebaDB.sdf”)和一个表(“tablaMercancia”)。
在 DataSource 中我还有“pruebaDBDataSet”和“tablaMercancia”。
如何在 DataGrid 中显示数据表?
我使用 SmartDevice 项目(我不能使用 DataGridView,我只能使用 DataGrid)。
我可以在 DataGrid 中显示一个新表(为代码创建),但我不知道在我的数据库中显示一个现有表。
string conSTR = "Data Source=" + (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)) + "\\pruebaDB.sdf;Persist Security Info=False";
SqlCeConnection connection = new SqlCeConnection(conSTR);
string sql = "SELECT * FROM tablaMercancia";
connection.Open();
SqlCeCommand cmd = new SqlCeCommand(sql, connection);
SqlCeDataAdapter da = new SqlCeDataAdapter(cmd);
//...............
//...Any idea?
//...............
connection.Close();
有什么想法吗?
谢谢!!!
【问题讨论】:
标签: c# sql database datagrid windows-mobile