I have run out of ways to determine the reason for a timeout error. The timeout is occuring on the
line indicated with ==>. After completing the statement before, the status of the connection
object(cn) is Open. After the timeout occurs and execution is transferred to the Catch block, the
connection is closed. Also, during the time the Update method is executing, the CPU usage in Windows
Task Manager is pegged.
What can I do to determine the cause of this timeout? Thanks for the help,
Lars
Dim cn As New SqlConnection(ConnectionSettings.cnString)
Dim daMaster As New SqlDataAdapter("usp_UnivUseCode_Sell_All", cn)
Dim daDetail As New SqlDataAdapter("usp_UnivUseCodeMap_Sell_All", cn)
Dim tblMaster As DataTable = ds.Tables(0)
Dim tblDetail As DataTable = ds.Tables(1)
daMaster.InsertCommand = Me.CreateInsertCommandUse(cn)
daMaster.UpdateCommand = Me.CreateUpdateCommandUse(cn)
daMaster.DeleteCommand = Me.CreateDeleteCommandUse(cn)
daDetail.InsertCommand = Me.CreateInsertUpdateCommandMap(cn)
daDetail.UpdateCommand = Me.CreateInsertUpdateCommandMap(cn)
daDetail.DeleteCommand = Me.CreateDeleteCommandMap(cn)
cn.Open()
Try
' Submit the only new Master/Detail rows
daMaster.Update(tblMaster.Select(Nothing, Nothing, DataViewRowState.Added))
==> daDetail.Update(tblDetail.Select(Nothing, Nothing, DataViewRowState.Added))
' Submit the only modified Master/Detail rows
...
Catch ex As SqlException
MessageBox.Show(ex)
End Try
cn.Close()
Private Function CreateInsertUpdateCommandMap(ByVal cn As SqlConnection) As SqlCommand
Dim cmd As New SqlCommand("usp_UnivUseCodeMap_Save", cn)
cmd.CommandType = CommandType.StoredProcedure
Dim pc As SqlParameterCollection = cmd.Parameters
pc.Add("@CompID", SqlDbType.Int, 0, "CompID")
pc.Add("@UseCodeFK", SqlDbType.Int, 0, "UseCodeFK")
pc.Add("@UnivUseCode", SqlDbType.Char, 2, "UnivUseCode")
Return cmd