chandresh43
asked on
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
i get this error
void semilarproduct()
{
string strQuery = "SELECT TOP 3 * FROM shivproductwithsaleprice where subcategory='" + Lblsubcategory.Text + "' ORDER BY NEWID()";
SqlDataAdapter da = new SqlDataAdapter(strQuery, connStr);
DataTable dt = new DataTable();
da.Fill(dt);
Datamatchproduct.DataSource = dt;
Datamatchproduct.DataBind();
}
Are You Sure Your SQL Server Manager Returns the expected results in time ? Use Either Sql Query Analyzer if you found the delay is too high then check for Connectivity Issues in Sql Server , else if its okay then
Try adding a Connect Timeout in the web.config
<add key="DBConnection" value="server=LocalHost;ui d=sa;pwd=; database=D ataBaseNam e;Connect Timeout=200; pooling='true'; Max Pool Size=200"/>
Try adding a Connect Timeout in the web.config
<add key="DBConnection" value="server=LocalHost;ui
Best link to solve your problem. Various solutions of your problem.
http://tipsstation.com/article/Timeout-expired-server-is-not-responding-Asp-Dot-Net.aspx
http://tipsstation.com/article/Timeout-expired-server-is-not-responding-Asp-Dot-Net.aspx
Setting your Connection Timeout higher as princeatapi suggests makes sense, as does setting the Command Timeout higher, as the article from namazikhah suggests. These, and common network issues referenced by the article from roma2208 are worth checking into.
My additional suggestions are:
1. You should get higher performance from this query if you make it into a stored procedure.
2. Also you should probably consider an index on subcategory.
3. Finally, why are you ordering by NewID()? I don't know how much that is impacting performance, but I'm curious about what you are trying to accomplish with it.
My additional suggestions are:
1. You should get higher performance from this query if you make it into a stored procedure.
2. Also you should probably consider an index on subcategory.
3. Finally, why are you ordering by NewID()? I don't know how much that is impacting performance, but I'm curious about what you are trying to accomplish with it.
ASKER
how i make it in stored procedure.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
mainly the server IP
If the IP is unreachable then this kind of errors occurs
for example,
connection string looks like "Data Source=10.100.1.1;Initial Catalog=TEST;Persist Security Info=True;User ID=demo;Password=demo"