我正在编写 ac# gui,其中我有一个表单可以从商店获取有关库存的信息,并且我希望它在我有用户输入到 UPC 框点击确定时链接,其余的从微软访问文件自动填充。有没有办法做到这一点?除了通过双击按钮和文本框自动生成的代码之外,我没有任何代码。
问问题
391 次
2 回答
0
您需要在表单中添加用于显示信息的控件。然后你需要编写代码来查找数据库文件中的信息,一旦你有了,填写表单上已经存在的控件。
于 2011-12-06T15:59:09.810 回答
0
如果您尝试从 Microsoft Access DB 文件中读取数据,那么类似这样的内容将返回您需要的数据。重要的是要知道你想要得到什么。与此类似的东西将返回数据。然后从那里填充数据需要去的地方。
string ConString = @"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=
C:\DatabaseNameGoesHere.mdb";
OleDbConnection Con = new OleDbConnection(ConString);
OleDbCommand Command = Con.CreateCommand();
// create the DataSet
DataSet ds = new DataSet();
// clear the grids data source
PlaceToPutTheData.DataSource = null;
// open the connection
Con.Open();
// run the query
Command.CommandText = "Select the data from the table you need;
OleDbDataAdapter Adapter = new OleDbDataAdapter(Command);
Adapter.Fill(ds);
// close the connection
Con.Close();
// set the grid's data source
PlaceToPutTheData.DataSource = ds.Tables[0];
你的问题有点模糊,所以很难给你直接的答案,但希望这会给你一个开始和帮助。
于 2011-12-06T16:08:10.530 回答