通过sql语句insert into插入数据,代码正常运行,在DataGridView能够显示增加的数据,但是Access数据库没有更新,是什么原因啊?求救啊各位大神
public void updatecon() // 写入并更新数据
{
OleDbCommand incmd;
OleDbDataAdapter inda;
DataSet inds;
string id = textBox2.Text;
string keyname = textBox3.Text;
string username = textBox4.Text;
string tel = textBox5.Text;
string time = textBox6.Text;
bool userempty = (username.Length == 0);
bool telempty = (tel.Length == 0);
if (userempty == true || telempty == true)
{
MessageBox.Show("请输入姓名和电话!");
}
else
{
try
{
tempcon.Open();
string insql = "insert into [UserInfo](ID,KeyName,[UserName],[Tel],[Time]) values ('" + id + "','" + keyname + "','" + username + "','" + tel + "','" + time + "')"; //选择用户数据表
//string insql = "select * from UserInfo"; //选择数据表
incmd = new OleDbCommand(insql, tempcon);
incmd.ExecuteNonQuery(); //执行
}
catch (Exception a)
{
throw a;
}
tempcon.Close();
}