"查询值的数目与目标字段中的数目不同。这个错误如何解决
privatevoidbtnAdd_Click(objectsender,EventArgse){stringusername=this.tbName.Text.Trim...
private void btnAdd_Click(object sender, EventArgs e)
{
string username = this.tbName.Text.Trim();
string pin = this.tbPwd.Text.Trim();
if (username != "" && pin != "")
{
StringBuilder sqlstr = new StringBuilder();
sqlstr.Append("INSERT INTO QX VALUES( ");
sqlstr.Append("'"+username+"','"+pin+"' ");
sqlstr.Append(")");
OleDbConnection mycn = new OleDbConnection(cns);
OleDbCommand mycm=new OleDbCommand(sqlstr.ToString(),mycn);
mycn.Open();
int n = mycm.ExecuteNonQuery();//此处出现错误···
if (n>0)
{MessageBox.Show("写入成功!", "系统提示:")}
else
{MessageBox.Show("写入失败!", "系统提示:");}
mycn.Close(); 展开
{
string username = this.tbName.Text.Trim();
string pin = this.tbPwd.Text.Trim();
if (username != "" && pin != "")
{
StringBuilder sqlstr = new StringBuilder();
sqlstr.Append("INSERT INTO QX VALUES( ");
sqlstr.Append("'"+username+"','"+pin+"' ");
sqlstr.Append(")");
OleDbConnection mycn = new OleDbConnection(cns);
OleDbCommand mycm=new OleDbCommand(sqlstr.ToString(),mycn);
mycn.Open();
int n = mycm.ExecuteNonQuery();//此处出现错误···
if (n>0)
{MessageBox.Show("写入成功!", "系统提示:")}
else
{MessageBox.Show("写入失败!", "系统提示:");}
mycn.Close(); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询