Switch to full style
You can find discussions, solutions and codes related to ASP.NET
Post a reply

Timeout error while updating record in SQLServer in ASP.NET

Thu Nov 06, 2008 3:09 pm

I have developed an ASP.NET application and the code listed below is
on the Update button, to update a record into the SQLServer
database.

The application works fine and I can retrieve the record and after
the any field is modified, I click the 'Update' button to update the
changes. However, I get the following error on the
line "ExeQry.ExecuteNonQuery()". The error displayed is "Timeout
expired. The timeout period elapsed prior to completion of the
operation or the server is not responding."

I am not able to figure out what is causing the error. I did find
out that if I updated any record in any table in this database
through "SQL Query Analyser" or "Enterprise Manager", then the below
code works fine. The application then works fine for a while and
then the same error is displayed again.

It seems like it is a connection issue with the database or the
database is set to an inactive state and hence causes the error. And
after an update is done on the database using "Query Analyser", the
connection is restored and hence the application starts working again

Has anybody on this group come across this issue. Please give me
some insight into what the problem is.




Code:


Private Sub btnUpdate_Click(ByVal sender As System.ObjectByVal e
As System.EventArgsHandles btnUpdate.Click
Dim strConn 
As String
Dim Conn 
As New SqlConnection
Dim strSQL 
As String
Dim ExeQry 
As SqlCommand

Try
strConn ConfigurationSettings.AppSettings("connectionString")
Conn = New SqlConnection(strConn)

'Test with simple statement
strSQL = " update StudentMovement "
strSQL = strSQL & " set Last_Update_By = '
In process' "
strSQL = strSQL & " where ECStudId = '" & Session("
ECStudId") & "'"
strSQL = strSQL & " and Movementid = '" & vMovementId & " "
ExeQry = New SqlCommand(strSQL, Conn)
Conn.Open()


ExeQry.ExecuteNonQuery()
Conn.Close()

LoadMovementRecords()

Catch exc1 As Exception
Response.Write(exc1.Message)
Finally
If Not (Conn Is Nothing) Then
If Conn.State = System.Data.ConnectionState.Open Then Conn.Close()
End If
End Try
End Sub




Re: Timeout error while updating record in SQLServer in ASP.NET

Thu Nov 06, 2008 3:10 pm

Make sure that the database is actually attached, that SQL Server is
running when you try to execute the code, and that
"connectionString" actually has a string pointing to the database.

Post a reply
  Related Posts  to : Timeout error while updating record in SQLServer in ASP.NET
 error in inserting record     -  
 need help in Sqlserver     -  
 selecting a record randomly from table     -  
 Connecting to SQLServer 2000 using JDBC     -  
 ERROR     -  
 Java error     -  
 Deliberate Error     -  
 skymiles error     -  
 Check DNS error     -  
 error in code     -  

Topic Tags

ASP Time