在web引用web service
using myservice;protected void btncheck_Click(object sender, EventArgs e)
{
string names = this.TextBox1.Text;
myservice.MYWebService check = new myservice.MYWebService();
//开始异步调用
IAsyncResult result = check.Beginexituser(names,null);
bool exits = check.Endexituser(names); if (exits)
{
this.Label1.Text = "此用户已经存在";
}
else
{
this.Label1.Text = "此用户不存在";
}
}
1. IAsyncResult result = check.Beginexituser(names,null,“参数a");谁能告诉我这个参数a怎么设置吗?
2.在这里为什么采用 IAsyncResult result = check.Beginexituser(names,null);
bool exits = check.Endexituser(names);异步调用?
请高手帮我解释一下?谢谢!!!
using myservice;protected void btncheck_Click(object sender, EventArgs e)
{
string names = this.TextBox1.Text;
myservice.MYWebService check = new myservice.MYWebService();
//开始异步调用
IAsyncResult result = check.Beginexituser(names,null);
bool exits = check.Endexituser(names); if (exits)
{
this.Label1.Text = "此用户已经存在";
}
else
{
this.Label1.Text = "此用户不存在";
}
}
1. IAsyncResult result = check.Beginexituser(names,null,“参数a");谁能告诉我这个参数a怎么设置吗?
2.在这里为什么采用 IAsyncResult result = check.Beginexituser(names,null);
bool exits = check.Endexituser(names);异步调用?
请高手帮我解释一下?谢谢!!!
解决方案 »
- 大量数据比较要存储结果很慢,求指教
- 关于C#生成的EXCEL中对于指定列生成XY散点图
- 对网络比较了解的进来讨论一下。
- 割脉咬舌跪求(C#数据库问题)
- 如何获取刚刚插入数据库的记录的ID?
- FTP下载的问题,从网上找了许多代码,但运行下载文件(我要下载的是.XML文件)都没完全下载成功. 求大家给个经测试一定可以下载文件成功的源
- 如何替换成等长字符串?急。。。。。
- 如何用.net 部署生成安装程序
- 请教一下,我怎么复制一下table的结构给一个新的表。我不要复制数据。
- 急!!!请版主及各高手兄弟请进!!!我特急,一个有关调用结构体问题!!!!!!!!多谢啊
- VC#里面的frame
- 关于<asp:textbox> 样式怎么设置
异步不等于同步地方就是不用等待被调用方法的返回值,而可以继续执行其他代码,
IAsyncResult result = check.Beginexituser(names,null);
bool exits = check.Endexituser(names);
这样调显示不出异步的效果的,刚调用异步,然后马上就调用它的返回值的
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data;
using System.Data.SqlClient;
/// <summary>
/// MYWebService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class MYWebService : System.Web.Services.WebService
{ public MYWebService()
{ //如果使用设计的组件,请取消注释以下行
//InitializeComponent();
} [WebMethod(Description="检查用户名是否存在指定的用户")]
public bool exituser(string username)
{
bool exitname = false;//默认用户表不存在指定的用户
SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=Eduask_Power;User ID=sa;Persist Security Info=false");
SqlCommand scom = new SqlCommand("select * from Ep_Student where Eps_Name=@username", conn);
//scom.Parameters.AddWithValue("@username",username);
scom.Parameters.Add("@username",SqlDbType.VarChar,50);
scom.Parameters["@username"].Value = username.ToString(); conn.Open();
SqlDataReader sdr = scom.ExecuteReader(CommandBehavior.CloseConnection);
if (sdr.Read())
{
exitname = true;
}
sdr.Close();
return exitname;
}
[WebMethod(Description = "获取服务器当前时间")]
public DateTime getservertime()
{
return DateTime.Now;
}
}