textbox 和 combobox内容关联的问题
string mycombox = comboBox3.Text.Trim();if (comboBox3.SelectedItem.ToString() == mycombox )
{
OleDbConnection thisconn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Windows.Forms.Application.StartupPath + "/CnEduCode.mdb");
OleDbCommand mycomm = new OleDbCommand();
mycomm.Connection = thisconn;//初始化connection
= "select Cn_SoftID from Cn_CustomEdit where Cn_CusName ='" + mycombox + "'";
thisconn.Open();//打开连接
OleDbDataReader thisread = mycomm.ExecuteReader();
while (thisread.Read())
{
string mycoid = Convert.ToString(thisread["Cn_SoftID"]);
cn_SoftIDTextBox.Text = mycoid;
thisread.Close();
return;
}
}
textbox和combobox内容都在数据库同一表中。当选中combobox的一个数据后,textbox显示与combobox内容相符的数据,如何做呀,上面错误在哪?
谢谢!