我正在尝试在 C# 中显示一个 DataGrid(适用于应用程序 WindowsMobile)。我在 DataConnections 中有一个数据库(“pruebaDB.sdf”)和一个表(“tablaMercancia”)。
同样在数据源中,我有“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();
请问有什么想法吗?
谢谢!!!