Conn.Open();
string strInsert="insert into admin(name,password) values('"+TextBox1.Text+"','"+TextBox2.Text+"')";
OleDbCommand InsertComm = new OleDbCommand(strInsert,Conn);
InsertComm.ExecuteNonQuery();
Conn.Close();异常详细信息: System.Data.OleDb.OleDbException: INSERT INTO 语句的语法错误。
string strInsert="insert into admin(name,password) values('"+TextBox1.Text+"','"+TextBox2.Text+"')";
OleDbCommand InsertComm = new OleDbCommand(strInsert,Conn);
InsertComm.ExecuteNonQuery();
Conn.Close();异常详细信息: System.Data.OleDb.OleDbException: INSERT INTO 语句的语法错误。
strInsert 是字符串呀,所写的各个字段时非空字段。做出,烦呀!
如果是真的,那么错误是 access数据库进行插入或者更新的时候对 int 字段不能用 '',比如说'"+ password.Text +"' ,应该写成 "+ password.Text +" ,去掉外面的'',而且最好先把password.Text 转换成 int如果你用的是 SQL 服务器,看看有没有类型匹配的问题```
string strInsert="insert into admin([name],[password]) values('"+TextBox1.Text+"','"+TextBox2.Text+"')";
OleDbCommand InsertComm = new OleDbCommand(strInsert,Conn);
InsertComm.ExecuteNonQuery();
这样就可以了,谢谢!