如何重新初始化form或者textbox?
我想增加新数据后,可以像未加新数据前那样,点击datagridview可以在textbox中显示对应内容。请问如何才可?private void button2_Click(object sender, EventArgs e)
{
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");
OleDbCommand mycomm = new OleDbCommand();
mycomm.Connection = thisconn;//初始化connection
= "select Cn_SoftCode from Cn_SoftWare where Cn_SoftCode ='" + thiscncode + "'";
thisconn.Open();//打开连接
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("添加完成!");
}
databind(); //datagridview即时显示数据库内容
thisconn.Close();//关闭连接
return;
}