可以先写一个类,来访问数据,一切妥当了,复制,粘贴。WebService和普通程序的区别就在于方法前加了[WebMothed]属性
解决方案 »
- 代码请教
- 谁有通用的短信猫动态库(可用于西门子、WAVECOM等GSM模块的)?
- 不区分大小写A和HREF (?is)<A\sHREF=""([^>]+?)"">([^>]+?)</A>
- 无法将类型"Response result"隐式转换为"DataTable"
- 如何把照片或者PDF、EXCEL,上传到指定目录,之后把路径保存到数据库表里,再从表里读照片路径,再显示。
- ~~~批量关闭子窗体~大家来挑战一下啦~~~
- 获取文件信息老出错,请大家帮我看看!
- 下面代码可以用循环语句完成吗?给出代码。
- 两行超级简单的代码让你的程序直接崩溃,请指出原因!
- C#里iTextSharp处理PDF文档,报对象不存在,大神可以帮忙看看吗
- 在 window2003 下.如何发布 web 应用程序啊.
- C#里有没有属性页(property sheet) 的组件呀??
服务器代码:
[WebMethod]
public DataSet returnDataSet(string strSql)
{
SqlConnection custConn=new SqlConnection(ConfigurationSettings.AppSettings["wsURL"]) ;
SqlDataAdapter custDA = new SqlDataAdapter(strSql, custConn);
custConn.Open();
DataSet ds=new DataSet();
custDA.Fill(ds,"User");
custConn.Close();
return ds;
}
客户端代码为: private void button1_Click(object sender, System.EventArgs e)
{
DataSet ds1;
localhost.Service1 ser1 =new localhost.Service1();
ser1.Url=ClsWeb.strUrl;
ds1= ser1.RtuDataSet("select * from User where [姓名]='"+this.textBox1.Text+"' AND [密码]='"+this.textBox2.Text+"'");
try
{
if ((int)(ds1.Tables[0].Rows.Count)>0)
{ MessageBox.Show("是!");
}
else
{
MessageBox.Show("否!");
}
}
catch
{
MessageBox.Show("失败!");
}
}
不知道这么写对不对,请高手再指点一下!
到配置文件里面找。web.config