Click here to Skip to main content
15,900,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have using connection string as below

HTML
<add name="ConnectionString" connectionstring="User Id = sa; Password = sa; Database = CineVistaDB; Data Source=VEERESH\SQLEXPRESS;" />


If i use Data Source name like this,i'm getting timeout exception while running any Stored procedure.Addition, i know that stored procedure having single T-Sql statement and runs fastly at query runnung window.Please reply to

How to solve this and to change Data source name with ip address of PC,something like Data Source=192.168.0.68
Posted
Updated 18-Dec-11 20:09pm
v2

Increase value for Timeout of your SQL Connection & SQL Command

For Connection in Web.Config,
<add key="ConnectionString" value="server=(local); uid=sa; password=sa; database=master;Connection Timeout=30" />

For Command,
public void CreateSqlCommand()
{
   SqlCommand cmd = new SqlCommand();
   cmd.CommandTimeout = 15;
   cmd.CommandType = CommandType.Text;
}

& also take a look at the following page.
Troubleshooting: Timeout expired[^]

Free attachment
DBA’s Quick Guide to Timeouts[^]
 
Share this answer
 
Comments
Wendelius 19-Dec-11 16:24pm    
Good answer, 5.
you have to use this code to avoid this problem

using System<pre lang="c#"></pre>.Data.SqlClient;


SqlCommand GstCommand = new SqlCommand();
GstCommand.CommandTimeout = 60;


after adding this code you will not face this problem.
 
Share this answer
 
If your excep not remove using above solution,then
you just verify your query(from stored procedure)execution time.
and optimize your query.
becoz your query take more time than server resp time.
that way timeout error excep occured.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900