c# update语句,access报错
stringdate=comboBox2.Text+"-"+comboBox4.Text+"-"+comboBox5.Text;stringupdatecmd="UPDA...
string date =comboBox2.Text+"-"+comboBox4.Text+"-"+comboBox5.Text;
string updatecmd = "UPDATE consume SET ID =@ID,datetime=@datetime,type =@type,categate =@categate,money=@money,descrition=@money where ID=@ID";
oleDbCommand1 = new OleDbCommand(updatecmd,oleDbConnection1);
oleDbCommand1.Parameters.Add(new OleDbParameter("@ID",OleDbType.Integer,10));
oleDbCommand1.Parameters["@ID"].Value = textBox1.Text.Trim();
oleDbCommand1.Parameters.Add(new OleDbParameter("@datetime", OleDbType.DBDate, 10));
oleDbCommand1.Parameters["@datetime"].Value = date;
oleDbCommand1.Parameters.Add(new OleDbParameter("@type", OleDbType.Char, 6));
oleDbCommand1.Parameters["@type"].Value = comboBox1.Text;
oleDbCommand1.Parameters.Add(new OleDbParameter("@categate",OleDbType.Char,10));
oleDbCommand1.Parameters["@categate"].Value = comboBox3.Text;
oleDbCommand1.Parameters.Add(new OleDbParameter("@money",OleDbType.Integer,10));
oleDbCommand1.Parameters["@money"].Value = textBox3.Text.Trim();
oleDbCommand1.Parameters.Add(new OleDbParameter("@descrition",OleDbType.Char,50));
oleDbCommand1.Parameters["@descrition"].Value = textBox2.Text.Trim();
oleDbCommand1.Parameters.Add(new OleDbParameter("@ID", OleDbType.Integer, 10));
oleDbCommand1.Parameters["@ID"].Value = textBox1.Text.Trim();
oleDbCommand1.Connection.Open();
oleDbCommand1.ExecuteNonQuery();
oleDbCommand1.Connection.Close();
大侠们救我 展开
string updatecmd = "UPDATE consume SET ID =@ID,datetime=@datetime,type =@type,categate =@categate,money=@money,descrition=@money where ID=@ID";
oleDbCommand1 = new OleDbCommand(updatecmd,oleDbConnection1);
oleDbCommand1.Parameters.Add(new OleDbParameter("@ID",OleDbType.Integer,10));
oleDbCommand1.Parameters["@ID"].Value = textBox1.Text.Trim();
oleDbCommand1.Parameters.Add(new OleDbParameter("@datetime", OleDbType.DBDate, 10));
oleDbCommand1.Parameters["@datetime"].Value = date;
oleDbCommand1.Parameters.Add(new OleDbParameter("@type", OleDbType.Char, 6));
oleDbCommand1.Parameters["@type"].Value = comboBox1.Text;
oleDbCommand1.Parameters.Add(new OleDbParameter("@categate",OleDbType.Char,10));
oleDbCommand1.Parameters["@categate"].Value = comboBox3.Text;
oleDbCommand1.Parameters.Add(new OleDbParameter("@money",OleDbType.Integer,10));
oleDbCommand1.Parameters["@money"].Value = textBox3.Text.Trim();
oleDbCommand1.Parameters.Add(new OleDbParameter("@descrition",OleDbType.Char,50));
oleDbCommand1.Parameters["@descrition"].Value = textBox2.Text.Trim();
oleDbCommand1.Parameters.Add(new OleDbParameter("@ID", OleDbType.Integer, 10));
oleDbCommand1.Parameters["@ID"].Value = textBox1.Text.Trim();
oleDbCommand1.Connection.Open();
oleDbCommand1.ExecuteNonQuery();
oleDbCommand1.Connection.Close();
大侠们救我 展开
展开全部
oleDbCommand1.Parameters["@ID"].Value = textBox1.Text.Trim();
oleDbCommand1.Parameters["@money"].Value = textBox3.Text.Trim();
这俩都是整型, 后面改为 int.parse(textBox1.Text.Trim())
oleDbCommand1.Parameters["@ID"].Value = int.parse(textBox1.Text.Trim())
oleDbCommand1.Parameters["@money"].Value = int.parse(textBox3.Text.Trim())
oleDbCommand1.Parameters["@money"].Value = textBox3.Text.Trim();
这俩都是整型, 后面改为 int.parse(textBox1.Text.Trim())
oleDbCommand1.Parameters["@ID"].Value = int.parse(textBox1.Text.Trim())
oleDbCommand1.Parameters["@money"].Value = int.parse(textBox3.Text.Trim())
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
string updatecmd = "UPDATE consume SET ID =@ID,datetime=@datetime,type =@type,categate =@categate,money=@money,descrition=@money where ID=@ID";
错误点:SET ID==@ID,where ID=@ID,作为条件的ID不能出现在更新里面,你也更新不了。
错误点:SET ID==@ID,where ID=@ID,作为条件的ID不能出现在更新里面,你也更新不了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
oleDbCommand1.Parameters["@ID"].Value = int.Parse(textBox1.Text);
oleDbCommand1.Parameters["@money"].Value = int.Parse(textBox3.Text);
oleDbCommand1.Parameters["@money"].Value = int.Parse(textBox3.Text);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
把每个字段加上 [] (比如 [uname]) 试试..
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询