Total members 10249 | Gratitudes |It is currently Thu May 17, 2012 7:32 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 2 posts ] 
Author Question
 Question subject: Timeout error while updating record in SQLServer in ASP.NET
PostPosted: Thu Nov 06, 2008 3:09 pm 
Offline
Proficient
User avatar

Joined: Sun Oct 19, 2008 3:47 pm
Posts: 281
Has thanked: 0 time
Have thanks: 1 time

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.Object, ByVal e
As System.EventArgs) Handles 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


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Timeout error while updating record in SQLServer in ASP.NET
PostPosted: Thu Nov 06, 2008 3:10 pm 
Offline
Proficient
User avatar

Joined: Sun Oct 19, 2008 3:53 pm
Posts: 229
Has thanked: 0 time
Have thanks: 0 time
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.


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 2 posts ] 
Quick reply


  

 Similar topics
 HELP :Novel error tolerant method AES for satelite imgaes
 ERROR
 error closing file matlab save
 error in code
 AJAX SYNTAX ERROR IE
 error in inserting record
 Java download error
 tell the meaning of the error
 Java error
 Understanding PHP error messages

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team