[RESOLVED] transaction and timeout error
in a transaction.commit i revceive the following error
"Timeout. The period of the timeout elapsed before the completion of the operation or the server is not responding"
any idea??
i use this code..
Code:
Dim dra As SqlDataReader
Dim con As SqlConnection = New SqlConnection(Session("DBConString"))
con.Open()
Dim thisTransaction As SqlTransaction
thisTransaction = con.BeginTransaction()
Try
Dim id As Integer = e.Item.ItemIndex + (CType(lbl_curpage.Text, Integer) - 1) * Session("arowsanapage")
Dim mycommanda As New SqlCommand("select text_caption,melosegrapse from t_text where katigoria=" & Session("katigoria") & " and thread=" & Session("thread") & " and text_id=" & id + 1, con)
mycommanda.CommandTimeout = 0
mycommanda.Transaction = thisTransaction
Dim text As String
Dim sigrafeas As String = ""
dra = mycommanda.ExecuteReader()
If Not dra Is Nothing Then
text = ""
While dra.Read()
text = dra(0)
sigrafeas = dra(1)
End While
dra.Close()
Else
text = ""
End If
dra.Close()
If Not text = e.CommandArgument Then
Session("lathos") = True
Session.Add("messagelathous", "κανε refresh και ξαναπροσπαθησε")
messagelabel.Focus()
Application("kleidomapost") = 0
Response.Redirect(Request.Url.ToString(), False)
Exit Sub
End If
Dim username As String = User.Identity.Name.ToString
' Dim id As String
Dim tid As String
id = e.Item.ItemIndex + (CType(lbl_curpage.Text, Integer) - 1) * Session("arowsanapage")
If role_authentication1(username.Trim) = False Then
If getusernameofthemanwhowrote(id + 1) <> username Then
Application("kleidomapost") = 0
Response.Redirect(Request.Url.ToString(), False)
Exit Sub
End If
End If
Dim dr As SqlDataReader
Dim mycommand As New SqlCommand("select top 1 text_id from t_text where katigoria=" & Session("katigoria") & " and thread=" & Session("thread") & " and text_id>0 order by text_id desc", con)
mycommand.CommandTimeout = 0
mycommand.Transaction = thisTransaction
Dim last_id As Integer
dr = mycommand.ExecuteReader()
If Not dr Is Nothing Then
While dr.Read()
last_id = dr(0)
End While
dr.Close()
Else
last_id = 0
Application("kleidomapost") = 0
Response.Redirect(Request.Url.ToString(), False)
Exit Sub
End If
dr.Close()
tid = id + 1
Dim paramar As SqlParameter
paramar = New SqlParameter("@id", SqlDbType.VarChar, 4)
paramar.Value = id
Dim sqlda As New SqlDataAdapter()
sqlda.SelectCommand = New SqlCommand()
sqlda.SelectCommand.CommandTimeout = 0
sqlda.SelectCommand.Transaction = thisTransaction
sqlda.SelectCommand.Parameters.Add(paramar)
sqlda.SelectCommand.Connection = con
sqlda.SelectCommand.CommandText = "delete from t_text where katigoria=" & Session("katigoria") & " and thread=" & Session("thread") & " and text_id>0 and text_id=" & id + 1
' Response.Write("diegrapse ston t_text")
Dim ds As New DataSet()
sqlda.Fill(ds)
ds.Dispose()
Dim i As Integer
If tid = last_id Then
' Response.Write(id)
Else
For i = tid + 1 To last_id
Dim mycommandttt As New SqlCommand("update t_text set text_id=" & i - 1 & " where katigoria=" & Session("katigoria") & " and thread=" & Session("thread") & " and text_id>0 and text_id=" & i, con)
mycommandttt.CommandTimeout = 0
mycommandttt.Transaction = thisTransaction
dr = mycommandttt.ExecuteReader()
dr.Close()
Next
End If
GridView1.EditItemIndex = -1
hgotopage.Items.Clear()
svisekoumpia()
If CType(lbl_curpage.Text, Integer) = CType(lbl_totalpages.Text, Integer) AndAlso GridView1.Items.Count = 1 Then
If CType(lbl_curpage.Text, Integer) > 2 Then
get_table_info()
populatelist(CType(lbl_totalpages.Text, Integer) - 1)
Else
get_table_info()
populatelist(0)
End If
Else
hgotopage.Items.Clear()
get_table_info()
If IsDBNull(lbl_curpage.Text) Then
populatelist(0)
Else
populatelist(CType(lbl_curpage.Text, Integer) - 1)
End If
End If
'get_table_info()
'populatelist(CType(lbl_curpage.Text, Integer) - 1)
Session("pageload") = lbl_totalpages.Text
valekoumpia()
thisTransaction.Commit()
Catch ex As Exception
Session("lathos") = True
Session("messagelathous") = ex.Message.ToString
thisTransaction.Rollback()
Finally
con.Close()
End Try
Re: transaction and timeout error
hay,
could you debug the code above step by step and post the line that throw the exception ?
Re: transaction and timeout error
ok the problem was the call of
get_table_info()
populatelist()
i removed them and it is ok
i dont know why
Re: transaction and timeout error
so this thread is resolved ?
if yes don't forget to mark it as resolved please :)
Re: transaction and timeout error
Quote:
Originally Posted by
vagelis
ok the problem was the call of
get_table_info()
populatelist()
i removed them and it is ok
i dont know why
If you removed them, then that would suggest that those methods were not required anymore, but that begs the question about why they were there in the first place.
Are you sure that you don't need them?
Gary
Re: [RESOLVED] transaction and timeout error
yes i dont need them i had them there before but i changed my code and i dont need them any more..
Re: [RESOLVED] transaction and timeout error
Ah, that makes sense then.
Gary