无效的 SQL语句;期待 'DELETE'、'INSERT'、'PROCEDURE'、'SELECT'、或 'UPDATE'。
大家帮忙看看是哪里错了string constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/App_Data/Hotels.mdb");
OleDbConnection con = new OleDbConnection();
con.ConnectionString = constr;
con.Open();
string cmdstr = string.Format(@"INSERT into checkin(RoomId,CurtomerId,CItime,PrePaid)
values('{0}','{1}','{2}','{3}')",TextBox1.Text,TextBox2.Text,DateTime.Today,Convert.ToInt16(TextBox3.Text));
OleDbCommand cmd = new OleDbCommand (cmdstr,con);
int i = cmd.ExecuteNonQuery();
if(i>0)
{
cmd.CommandText="Updata Room set state='入住' where RoomId ='"+TextBox1.Text+"'";
cmd.ExecuteNonQuery();
} --------------------编程问答-------------------- cmd.CommandText="Updata Room set state='入住' where RoomId ='"+TextBox1.Text+"'";
是update, 不是Updata --------------------编程问答--------------------
来晚了 --------------------编程问答--------------------
我是刚好路过的。
8-) --------------------编程问答--------------------
哈哈 --------------------编程问答--------------------
但是改过之后还是有错的,显示错误的代码就是cmd.ExecuteNonQuery();
这句代码多余还是错误啊?解释一下,二楼 --------------------编程问答-------------------- state='入住' 改为:
state="入住"
cmd.CommandText = "Update Room set state=" + "入住" + " where RoomId ='" + TextBox1.Text.ToString() + "'"; --------------------编程问答-------------------- 同意楼上的几个说法 --------------------编程问答--------------------
+2 --------------------编程问答-------------------- 显示什么错?把错误贴上来。 --------------------编程问答-------------------- update
--------------------编程问答--------------------
+1 --------------------编程问答-------------------- 错误:至少一个参数没有被指定值。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.OleDb.OleDbException: 至少一个参数没有被指定值。
源错误:
行 35: //cmd.CommandText="updata Room set state='入住' where RoomId ='"+TextBox1.Text+"'";
行 36: cmd.CommandText = "Update Room set state=" + "入住" + " where RoomId ='" + TextBox1.Text.ToString() + "'";
行 37: cmd.ExecuteNonQuery();
行 38:
行 39: }
--------------------编程问答-------------------- 给我两分呗!! --------------------编程问答-------------------- mark --------------------编程问答-------------------- 是不是sql语句拼接的错误!拼接出来是否没有空格!是否字符串用成了单引号!
补充:.NET技术 , ASP.NET