[C#] 纯文本查看 复制代码 private void button1_Click(object sender, EventArgs e)
{
var client = new ServiceReference1.WebService1SoapClient();
dataGridView1.DataSource = client.Get("姓名 like '%" + textBox1.Text.Trim() + "%'");
}
调用web服务
[C#] 纯文本查看 复制代码 public DataTable Get(string strwhere)
{
string strcon = " server = JIANG ; integrated security = SSPI; database = JJ";
StringBuilder strsql = new StringBuilder();
strsql.Append("select 工号,姓名 ");
strsql.Append(" from 登记表");
if ((strwhere != null) && (strwhere.Trim() != ""))
{
strsql.Append(" where " + strwhere);
}
SqlConnection con = new SqlConnection(strcon);
SqlDataAdapter da = new SqlDataAdapter(strsql.ToString(), con);
DataSet ds = new DataSet();
con.Open();
da.Fill(ds, "ds");
return ds.Tables[0];
}
为什么dataGridView1 不显示数据?
菜鸟求指导
|