A
ahmeddc
Guest
hi
I used the following function
To fill in the dataset from the database
And everything was done perfect.
I have a problem: it is when the internet connection is poor.
The program remains without error and works without stopping.
I don't get any data from the server. or timeout of connection
Is there a way to catch an error at the end of a certain time from connecting to the server, in case no data is obtained?
Public Sub fillDATASETA(ByVal ds As DataSet, ByVal tablename As String, ByVal query As String)
con.Open()
Using cmd As SqlCommand = New SqlCommand(query, con)
Using DataAdapter = New SqlDataAdapter(cmd)
cmd.CommandTimeout = 30
ds.Clear()
DataAdapter.Fill(ds, tablename)
con.Close()
End Using
End Using
End Sub
My attempt to catch a bug when the wait is long or the internet is weak BUT NOT WORK
Try
fillDATASETA( DSMANGMANG, "SETTING", "SELECT * FROM SETTING")
Catch ex As System.Data.SqlClient.SqlException
If (ex.Number = -2) Then
con.Close()
'ERROR There is too much time without data
End If
Catch ex As Exception
con.Close()
'ERROR
End Try
Continue reading...
I used the following function
To fill in the dataset from the database
And everything was done perfect.
I have a problem: it is when the internet connection is poor.
The program remains without error and works without stopping.
I don't get any data from the server. or timeout of connection
Is there a way to catch an error at the end of a certain time from connecting to the server, in case no data is obtained?
Public Sub fillDATASETA(ByVal ds As DataSet, ByVal tablename As String, ByVal query As String)
con.Open()
Using cmd As SqlCommand = New SqlCommand(query, con)
Using DataAdapter = New SqlDataAdapter(cmd)
cmd.CommandTimeout = 30
ds.Clear()
DataAdapter.Fill(ds, tablename)
con.Close()
End Using
End Using
End Sub
My attempt to catch a bug when the wait is long or the internet is weak BUT NOT WORK
Try
fillDATASETA( DSMANGMANG, "SETTING", "SELECT * FROM SETTING")
Catch ex As System.Data.SqlClient.SqlException
If (ex.Number = -2) Then
con.Close()
'ERROR There is too much time without data
End If
Catch ex As Exception
con.Close()
'ERROR
End Try
Continue reading...