传过来的字符串是zhou,limd,edce,decc....有无数个
怎么把他替换成'zhou','limd','edce','decc'....
其实就是要符合数据库的查询
select * from RecordFile where OperatorID in('zhou','limd','edce','decc')
怎么在C#中操作
或者在存储过程中也可以.
谢谢了.
怎么把他替换成'zhou','limd','edce','decc'....
其实就是要符合数据库的查询
select * from RecordFile where OperatorID in('zhou','limd','edce','decc')
怎么在C#中操作
或者在存储过程中也可以.
谢谢了.
string str="zhou,limd,edce,decc";
str= "'"+str.Replace(",","','")+"'";
strtmp ="";
for (int i=0; i < arr.length;i++)
{
// 最好采用StringBuffer
strtmp += "'" + arr[i] + "',";
}
if (strtmp.length()>0) strtmp=strtmp.substring(0,strtmp.length()-1);
string result=System.Text.RegularExpressions.Regex.Replace("zhou,limd,edce,decc....",@"(?<=^|,)(\w+)","'$1'");
str = Regex.Replace(str, @"\w+", "'$0'");非正则: string str = "zhou,limd,edce,decc";
string[] arr = str.Split(',');
for (int i = 0; i < arr.Length; i++)
arr[i] = string.Concat("'", arr[i], "'");
str = string.Join(",", arr);
declare @str varchar(100)
set @str = 'zhou,limd,edce,decc'
set @str = '''' + replace(@str,',',''',''')+''''
print @str
set @User = REPLACE(@Operatorid,',',''',''')