Total members 11890 |It is currently Wed Apr 24, 2024 6:35 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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





Author:
Proficient
User avatar Posts: 280
Have thanks: 1 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.

_________________
Please recommend my post if you found it helpful


Author:
Proficient
User avatar Posts: 228
Have thanks: 0 time
Post new topic Reply to topic  [ 2 posts ] 

  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
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com