我想在列移动之前添加数字30。我正在使用此代码: 我该怎么做?
using (var command = new SqlCommand("select mobile from memberform where active=1 or active=0", con)) // only retrieve the column, you really need
using (var reader = command.ExecuteReader())
{
var stringBuilder = new StringBuilder();
while (reader.Read())
{
stringBuilder.Append(reader["mobile"] + ",");
}
string result = stringBuilder.ToString().TrimEnd(',',' ');
}
答案 0 :(得分:2)
您可以简单地连接该值,如
stringBuilder.Append("30" + reader["mobile"] + ",");
(OR)
更改您的SQL查询本身,如
select '30' + mobile as mobile_number
from memberform
where active in (1 ,0);