急!! 有时间的近来看看.
StringBuilder connsql = new StringBuilder();
connsql.Append("select test.id,name,city,sex stature from test,detail where test.id=detail.id");
//string connsql = "select test.id,name,city,sex stature from test,detail where test.id=detail.id";
if (TextBox1.Text.Length != 0)
{
//connsql += "and test.id =" + TextBox1.Text.ToString();
connsql.Append("and test.id in (").Append(TextBox1.Text).Append(')');
}
sqlcmd = new SqlCommand(connsql.ToString(), sqlconn);
sqlda = new SqlDataAdapter(sqlcmd);
ds = new DataSet();
sqlda.Fill(ds, "select");
GridView1.DataSource = ds.Tables["select"];
GridView1.DataBind();
我是这样写的 TextBox1里面无值能正常运行 有值在sqlda.Fill(ds, "select");行显示 第 1 行: 'test' 附近有语法错误。为什么啊?!