注册 登录
编程论坛 ASP.NET技术论坛

如何将表达式付给数据库字段,

馨馨 发布于 2008-04-22 20:45, 773 次点击
如:a = Convert.ToInt32(jhshuliang.Text) * Convert.ToInt32(danjia.Text);
SqlCommand comm1 = new SqlCommand("insert into purchaselist (grandtotal) values (a)", conn);
这样写对吗?
错误提示:在此上下文中不允许使用 'a'。此处只允许使用常量、表达式或变量。不允许使用列名。
1 回复
#2
冰彩虹2008-04-22 21:04
SqlCommand comm1 = new SqlCommand("insert into purchaselist (grandtotal) values (" + a +")", conn);
1