SqlCommand myCommand = new SqlCommand("select id from b2cuser where sitedomain='12312'", myConnection);//原语句
我要把where后面的做成参数@sqlwhere
写成这样
sqlwhere = "sitedomain='12312'";
SqlCommand myCommand = new SqlCommand("select id from b2cuser where @sqlwhere", myConnection);
myCommand.Parameters.Add(new SqlParameter("@sqlwhere",sqlwhere));]]
执行的时候不对.问下怎么改
解决方案 »
- 关于ashx session保存用户信息问题
- 往一个逗号分割的字符串数组中在加一个数据如何加
- Firefox 的 javascript调试器 是什么?
- ASP.NET使用线程自动发送邮件
- 请教一个asp.net的基础问题:页面IsPostBack对GridView中checkbox列选择状态的影响
- 用户控件插入图片问题
- 谁知道好一点的老外论坛。告诉一声
- 在地址栏中动态生成的一种网址身份验证的是叫什么来个?怎么用?
- 急急啊,asp.net中的file组件,为何在提交后不能取得其属性,还报错.
- 这是原来写的一段vbscript函数,想将其转换为c#代码,大家进来看看,谢谢!
- 谁有关于服务器控件对应的客户端控件的属性及事件的详尽帮助手册?
- 含ajax.js文件的.net网站发布失败??
myCommand.Parameters["@sqlwhere"]=sqlwhere;
SqlCommand myCommand = new SqlCommand("select id from b2cuser where @sqlwhere", myConnection);
myCommand.Parameters.Add("@sqlwhere",SqlDbType.VarChar);
myCommand.Parameters["@sqlwhere"].Value = sqlWhere;
SqlCommand myCommand = new SqlCommand("select id from b2cuser where sitedomain=@sqlwhere", myConnection);
myCommand.Parameters.Add(new SqlParameter("@sqlwhere",sqlwhere));
create procedure SelectCmd(@tiaojian varchar(100))
as
begin
exec('select id from b2cuser where '+@tiaojian)
end
然后执行这个存储过程,不知道可以不
SqlCommand myCommand = new SqlCommand("select id from b2cuser where @sqlwhere", myConnection);
myCommand.Parameters.AddWithValue(new SqlParameter("@sqlwhere",sqlwhere));]]
sqlwhere = "'12312'";
SqlCommand myCommand = new SqlCommand("select id from b2cuser where sqlwhere=@sqlwhere", myConnection);
myCommand.Parameters.AddWithValue("@sqlwhere",sqlwhere);