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




Reply With Quote