string sql = "insert into studentInfo(studentID,studentName,studentSex,studentIDcard,studentAddress,bb) values('','"+tbxName.Text+"','"+tbxSex.Text+"','"+tbxID.Text+"','"+tbxAddress.Text+"','') "; SqlCommand cmd = new SqlCommand(sql,conn); cmd.ExecuteNonQuery();
------解决方案-------------------- string sql = "insert into studentInfo(studentID,studentName,studentSex,studentIDcard,studentAddress,bb) values('','"+tbxName.Text+"','"+tbxSex.Text+"','"+tbxID.Text+"','"+tbxAddress.Text+"','') ";
你定义的类型是 int 数字类型的 但赋值的时候是 ‘’ 表示字符类型的
如果你的studentid 为自增的,那就不要插入了
insert into studentInfo(studentName,studentSex,studentIDcard,studentAddress,bb) values('"+tbxName.Text+"','"+tbxSex.Text+"','"+tbxID.Text+"','"+tbxAddress.Text+"','') ";