Webservice超时,看不出原因

时间:2015-10-30 16:36:28

标签: c# web-services

我已经创建了Web服务和Webclient。但是,我一直在超时,无法弄清楚它在哪一侧。它告诉我它发生在这一行:

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调用此函数的唯一实例。这是Webservice中的功能:

 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;
    }
}

为什么会发生这种情况?我可以单独离开页面一分钟,然后尝试做一些事情,然后超时就会发生。如果我足够快,页面上的所有内容都可以正常工作。

感谢您的任何建议!

0 个答案:

没有答案
相关问题