Thank you Cowboy, you were right on.
Many thanks again. Really appreciate it
"Cowboy (Gregory A. Beamer)" wrote:
> Command timeout. It is, in this case, more important than the connection
> timeout.
>
> --
> Gregory A. Beamer
> MVP, MCP: +I, SE, SD, DBA
>
> Subscribe to my blog
>
http://gregorybeamer.spaces.live.com/lists/feed.rss
>
> or just read it:
>
http://gregorybeamer.spaces.live.com/
>
> *************************************************
> | Think outside the box!
> |
> *************************************************
> "Ant" <Ant@discussions.microsoft.com> wrote in message
> news:7EA1DA38-B5BB-403A-A17B-0C232ACE6348@microsoft.com...
> > Hi,
> > I am trying to run a SP that takes about 90 seconds to complete. If i run
> > it
> > from SQL Server, it completes ok but if I run it from my .NET application,
> > I
> > get a timeout error after about 40 seconds.
> > I set the Connection timeout in the connection string builder to 180 but
> > it
> > still time out well before 3 minutes.
> > Is there anything else I should check?
> > Many thanks for any ideas on this
> > Ant
> >
> > below is the script:
> >
> > SqlConnectionStringBuilder connectionsString = new
> > SqlConnectionStringBuilder();
> >
> >
> > connectionsString.DataSource = "myserver";
> > connectionsString.InitialCatalog = backup.EpicorDB;
> > connectionsString.IntegratedSecurity = true;
> > connectionsString.ConnectTimeout = 1800;
> >
> > using (SqlConnection connection = new
> > SqlConnection(connectionsString.ToString()))
> > {
> > // create the command to call the SP
> > SqlCommand commandBackup = new SqlCommand("MyBackupLiveData",
> > connection);
> > commandBackup.CommandType = CommandType.StoredProcedure;
> >
> > // set an event to indicate SP has completed
> > commandBackup.StatementCompleted += new
> > StatementCompletedEventHandler(commandBackup_StatementCompleted);
> >
> > // create & load the params for the SP
> > SqlParameter paramOffice = new SqlParameter("@Office",
> > backup.Office);
> > SqlParameter paramSecurityDB = new SqlParameter("@secmanDB",
> > backup.securityDB);
> > SqlParameter paramEpicorDB = new SqlParameter("@E4SEDB",
> > backup.EpicorDB);
> > SqlParameter paramControlDB = new SqlParameter("@ControlDB",
> > backup.ControlDB);
> > SqlParameter paramCompanyDB = new SqlParameter("@CompanyDB",
> > backup.CompanyDB);
> >
> >
> > // add the params to the command
> > commandBackup.Parameters.Add(paramOffice);
> > commandBackup.Parameters.Add(paramSecurityDB);
> > commandBackup.Parameters.Add(paramEpicorDB);
> > commandBackup.Parameters.Add(paramControlDB);
> > commandBackup.Parameters.Add(paramCompanyDB);
> >
> >
> > try
> > {
> > connection.Open();
> >
> > // execute the SP
> > commandBackup.ExecuteNonQuery();
> > }
> > catch (Exception ex)
> > {
> > textboxCompleted.ForeColor = System.Drawing.Color.Red;
> > textboxCompleted.Text = ex.Message + "\r\n\r\nPlease check
> > the name of your database & try again";
> > textboxOfficeName.Text = string.Empty;
> > }
> >
> >
> >
> > finally
> > {
> >
> > connection.Close();
> > }
> >
>
>