C# Webservice超时,can';我不明白为什么
我已经创建了一个Webservice和一个Webclient。然而,我一直在超时,不知道它在哪一边。它告诉我它发生在这条线上:C# Webservice超时,can';我不明白为什么,c#,web-services,C#,Web Services,我已经创建了一个Webservice和一个Webclient。然而,我一直在超时,不知道它在哪一边。它告诉我它发生在这条线上: Line 32: DropDownList1.DataSource = ordersAgent.getCustomers(); 我查看了客户端中的代码: public void Page_Init(object sender, EventArgs e) { empName = "Nancy"; empId = "1"; Lab
Line 32: DropDownList1.DataSource = ordersAgent.getCustomers();
我查看了客户端中的代码:
public void Page_Init(object sender, EventArgs e)
{
empName = "Nancy";
empId = "1";
Label1.Text = empId.ToString() + ". " + empName.ToString();
DropDownList1.DataSource = ordersAgent.getCustomers();
DropDownList1.DataValueField = "CompanyName";
DropDownList1.DataValueField = "CompanyName";
DropDownList1.DataBind();
DropDownList2.DataSource = ordersAgent.getSuppliers();
DropDownList2.DataValueField = "CompanyName";
DropDownList2.DataValueField = "CompanyName";
DropDownList2.DataBind();
TextBox1.Text = DateTime.Now.ToString();
GetProducts();
}
这是从Webservice调用此函数时的唯一实例。这是Web服务中的功能:
public DataSet getCustomers()
{
string strProject = "ARTUR\\SQLEXPRESS"; //Enter your SQL server instance name
string strDatabase = "Northwind"; //Enter your database name
string strUserID = "Artlemaks"; // Enter your SQL Server User Name
string strPassword = "rootUser"; // Enter your SQL Server Password
string strconn = "data source=" + strProject +
";Persist Security Info=false;database=" + strDatabase +
";user id=" + strUserID + ";password=" +
strPassword + ";Connection Timeout = 0";
using (System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(strconn))
{
//' declare the command that will be used to execute the select statement
SqlCommand cmdOrders = new SqlCommand("SELECT CompanyName FROM Customers", con);
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmdOrders);
DataSet ds = new DataSet();
da.Fill(ds, "ss");
con.Close();
return ds;
}
}
知道为什么会这样吗?我可以让页面单独呆一分钟,然后尝试做一些触发事件的事情,然后超时就会出现。如果我足够快,页面上的所有内容都可以正常工作
谢谢你的建议 超时的完整堆栈跟踪是什么?我猜它粘在了
da.Fill
?如果通过查询窗口运行查询,需要多长时间?有多少客户?完整的堆栈跟踪太长,无法粘贴到评论中,因此我将其放置在此处:@JohnPaul第一次运行时大约需要30秒。只有91条记录您在数据库中使用的是什么?91条记录应立即返回。超时的完整堆栈跟踪是什么?我猜它粘在了da.Fill
?如果通过查询窗口运行查询,需要多长时间?有多少客户?完整的堆栈跟踪太长,无法粘贴到评论中,因此我将其放置在此处:@JohnPaul第一次运行时大约需要30秒。只有91条记录您在数据库中使用的是什么?91条记录应立即返回。