|
34 days ago I posted a question on what is the VB code to know if a table is existing in MySQL, but I have not receive any reply. I hope that the following code will help the reader determine what is the problem after the "Do While Not .EOF" code.
Private Sub CheckTable() Dim gcnDb As ADODB.Connection Dim grsRs As ADODB.Recordset Set gcnDb = New ADODB.Connection Set grsRs = New ADODB.Recordset DbNameMySQL = "mydata" sTemp = "DATABASE=" & DbNameMySQL & ";" With gcnDb .ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" & _ "SERVER=" & ServerMySQL & ";" & sTemp & _ "USER=" & UserNameMySQL & ";" & _ "PASSWORD=" & PasswordMySQL & ";" & _ "PORT=" & PortMySQL & ";" & _ "OPTION=" & OptionMySQL & ";" .CursorLocation = adUseClient .Open End With Set grsRs = gcnDb.Execute("SHOW TABLES FROM " & DbNameMySQL) With grsRs If Not .RecordCount = 0 Then .MoveFirst Do While Not .EOF If LCase(DbNameMySQL) = .Fields("TABLE").Value Then MsgBox "Table already exist!" Exit Do End If .MoveNext Loop End If End With grsRs.Close Set grsRs = Nothing gcnDb.Close End Sub
|