读取数据库出错
OleDbConnection thisconn01 = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Windows.Forms.Application.StartupPath + "/CnEduCode.mdb");
OleDbCommand mycomm01 = new OleDbCommand();
mycomm01.Connection = thisconn01;
//mycomm1.Connection = thisconn1;
if (radioButton1.Checked)
{
mycomm01.CommandText = "select Cn_BuildTime,Cn_ReturnCode0,CnreturnCode1,Cn_VerifyCode0,Cn_VerifyCode1,Cn_RegTime0,Cn_RegTime1 From Cn_License Where Cn_LicStr='" + textBox1.Text.Trim() + "'";
thisconn01.Open();
OleDbDataReader thisread01 = mycomm01.ExecuteReader();
if (thisread01.Read())
{
//转化并在datagridview中显示
string xlhsj001 = Convert.ToString(thisread01["Cn_BuildTime"]);
string jqyjm001 = Convert.ToString(thisread01["Cn_ReturnCode0"]);
string jqyjm002 = Convert.ToString(thisread01["Cn_ReturnCode1"]);
string zch001 = Convert.ToString(thisread01["Cn_VerifyCode0"]);
string zch002 = Convert.ToString(thisread01["Cn_VerifyCode1"]);
string zcsj001 = Convert.ToString(thisread01["Cn_RegTime0"]);
string zcsj002 = Convert.ToString(thisread01["Cn_RegTime1"]);
dataGridView1.Rows.Add(textBox1.Text.Trim(), xlhsj001, jqyjm001, jqyjm002, zch001, zch002, zcsj001, zcsj002);
thisconn01 .Close ();
return;
}
else
{
MessageBox.Show("此人不存在!");
return;
}
}
为什么到 OleDbDataReader thisread01 = mycomm01.ExecuteReader();过不去呢?
提示"至少一个参数未指定值"
难道我还要先判断textbox.text.trim()在数据库存在与否,再根据情况是否读取与textbox.text要关联的数据?
谢谢!