我也需要这样的功能,我的是在GridView每一行后加一个checkbox,选择单行的话插入操作没有问题,只要一选择多行,就会出错。提示:varchar 值 '681,684 ' 转换为数据类型为 int 的列时发生语法错误。我的代码如下:
string Id_str = Request.Form["Checkbox"];
string Hid = check.getlist("abc", Id_str).Tables[0].Rows[0]["Hid"].ToString().Trim();
string time = DateTime.Now.ToShortDateString();
//这里用存储过程获取选中行的其他字段
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]);
conn.Open();
string sql = "insert into test(Hid,creattime)values('" + Hid + "','" + time + "')";
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.ExecuteNonQuery();
COMP.Jscript.AlertAndRedirect("提交成功!", "Defaulta.aspx");
conn.Close();拿来让高手帮看看,错在哪里,应该怎么改,谢谢!
string Id_str = Request.Form["Checkbox"];
string Hid = check.getlist("abc", Id_str).Tables[0].Rows[0]["Hid"].ToString().Trim();
string time = DateTime.Now.ToShortDateString();
//这里用存储过程获取选中行的其他字段
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]);
conn.Open();
string sql = "insert into test(Hid,creattime)values('" + Hid + "','" + time + "')";
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.ExecuteNonQuery();
COMP.Jscript.AlertAndRedirect("提交成功!", "Defaulta.aspx");
conn.Close();拿来让高手帮看看,错在哪里,应该怎么改,谢谢!
解决方案 »
- 用asp.net做网上书店系统怎么做 啊?
- 这个语句报错是啥原因
- 我安装SQL Server2005,有两个,是安装基于 x64 操作系统的?还是 x86的?
- 触发器疑点。。。
- XP客户端出现用户'(null)' 登录失败。未与信任 SQL Server 连接相关联(服务器端WIN2003,SQL SERVER 2000 采用了混合验证)
- 查询各数据库耗时1000毫秒以上语句总数,请指教,谢谢!
- 求高手告诉我sql执行了那些功能
- 不知道这个SQL该怎么写,请指教
- 能否在客户端的“查询分析器”上停止SQL SERVER的服务?
- select * from table1 in 的存储过程怎么写呀?
- SQL出错!!!!!!!!
- 求一条SQL统计语句
declare @d datetime
set @d=getdate()
insert test (Hid,creattime)
select 选中的第1条的hid,@d
union all select 选中的第2条的hid,@d
union all select 选中的第3条的hid,@d
再一次提交
直接变成681684就行了
不知道怎么出来个这
没用过.net