I have use VB 2008 Express function to port a big MySql database into a DataGridView table:
1. If my strSQL uses only some AND fields and some LIKE fields, it works perfectly
2. If I add more then I have MySqlException: Timeout expired (see the attached image)
(even I tried couple of timeout commands which are highlight above, all are failed)
3. But if I use SQLyog tool with the same strSQL as #2 above, it works fine even it takes awhiclke to complete its task
Because my VB program needs to use strSQL #2, my questions are:
a. Can I improve my codes to prevent MySqlException Timeout happen? If YES, then how?
b. Is there any issue outside the VB codes that affected my case? If YES, please clarify them!
I am already stuck on this issue couple days and I did try to search some forums, but it seems nothing can help :cry:
I am appreciate anyone can provide any suggestion in my case :confused:
Code:
Function ScanDatabase()
Dim str_SQL As String
Dim Result As Boolean = True
If f_done = False Then
cnString = "datasource=" + s_HostAdress + ";username=" & s_UserID
cnString += ";password=" + s_Password + ";database=" + s_Database + ";Connect Timeout=6000000"
conn = New MySqlConnection(cnString)
End If
Try
If f_done = False Then
' Open connection
conn.Open()
Else
ListBox1.Items.Clear()
DataGridView1.Refresh()
End If
str_SQL = GetStringSQL_Search()
If str_SQL = "" Then
Return Result
End If
' Time out = 20 minutes
cmd.CommandTimeout = 1200
da = New MySqlDataAdapter(str_SQL, conn)
If f_done Then
ds.Clear()
End If
'create command builder
Dim cb As MySqlCommandBuilder = New MySqlCommandBuilder(da)
cmd.CommandTimeout = 1200
'fill dataset
da.Fill(ds, "Customers")
TextBox_CNT.Text = (DataGridView1.RowCount - 1).ToString
da.Dispose()
f_done = True
Catch ex As Common.DbException
Result = False
conn.Close()
MsgBox(ex.ToString)
Me.Close()
End Try
Return Result
End Function
2. If I add more then I have MySqlException: Timeout expired (see the attached image)
(even I tried couple of timeout commands which are highlight above, all are failed)
3. But if I use SQLyog tool with the same strSQL as #2 above, it works fine even it takes awhiclke to complete its task
Because my VB program needs to use strSQL #2, my questions are:
a. Can I improve my codes to prevent MySqlException Timeout happen? If YES, then how?
b. Is there any issue outside the VB codes that affected my case? If YES, please clarify them!
I am already stuck on this issue couple days and I did try to search some forums, but it seems nothing can help :cry:
I am appreciate anyone can provide any suggestion in my case :confused: