private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = "1,2,3";//测试
string[] ss = textBox1.Text.Trim().Split(new char[] { ',' });
string r = "(";
for (int i = 0; i < ss.Length - 1; i++)
{
r += string.Format("'{0}',", ss[i]);
}
r += string.Format("'{0}')", ss[ss.Length - 1]);
string sql = "select * from [TableName] where [ColumnName] in " + r;
MessageBox.Show(sql);
}
string sql = String.Format("select * from table where field1 in({0})", textBox1.Text.Trim());
select * from 表名 where 字段名 in (文本框的内容)
不知道 怎么写 就把逗号当分隔符处理掉