显示基于数据库 C#、数据库、WindowsApplication、
大家好,我有一个问题,如果我在代码列中根据我的数据库键入数字,我如何输入描述列,我已经从数据库中检索代码,但现在我也想在代码显示时显示描述。
这是我检索“代码”的代码(0001、0002 等)
string connectionString = (@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\Archives\Projects\Program\Sell System\Sell System\App_Data\db1.accdb;Persist Security Info=False;");
OleDbDataReader dReader;
OleDbConnection conn = new OleDbConnection(connectionString);
conn.Open();
OleDbCommand cmd = new OleDbCommand("SELECT DISTINCT [Code] FROM [Data]", conn);
dReader = cmd.ExecuteReader();
AutoCompleteStringCollection codesCollection = new AutoCompleteStringCollection();
while (dReader.Read())
{
string numString = "000" + dReader[0].ToString();
codesCollection.Add(numString);
}
dReader.Close();
conn.Close();