新人求 textbox中值与access中值比较
textbox中值与数据库的值比较,请指示,如何改?string thiscncode=cn_SoftCodeTextBox.Text.Trim();
OleDbConnection thisconn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Windows.Forms.Application.StartupPath + "/CnEduCode.mdb");
thisconn.Open();//打开连接
OleDbCommand mycomm = new OleDbCommand();
OleDbCommand thiscomm = thisconn.CreateCommand();
= "select Cn_SoftCode from Cn_SoftWare where Cn_SoftCode =" + thiscncode + "";
OleDbDataReader thisread = mycomm.ExecuteReader();
if (thisread.Read())
{
MessageBox.Show("软件编号已存在,请重新输入!");
thisread.Close();
return;
}
else
{
string article = "insert into Cn_SoftWare (Cn_SoftName,Cn_Remark,Cn_SoftCode) values('" + cn_SoftNameTextBox.Text + "','" + cn_RemarkTextBox.Text + "' ,'" + cn_SoftCodeTextBox.Text + "')";
OleDbCommand comm = new OleDbCommand(article, thisconn);//创建Command命令对象
comm.ExecuteNonQuery();//执行命令
MessageBox.Show("添加完成!");
运行出错图如下:
[[it] 本帖最后由 brightmoon 于 2008-11-21 14:31 编辑 [/it]]