VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3090 ScaleWidth = 4680 StartUpPosition = 3 'Windows Default Begin VB.CommandButton quit Caption = "Exit" Height = 615 Left = 2280 TabIndex = 5 Top = 1800 Width = 1575 End Begin VB.TextBox password Height = 285 IMEMode = 3 'DISABLE Left = 360 PasswordChar = "*" TabIndex = 3 Top = 2400 Width = 1455 End Begin VB.TextBox userName Height = 285 Left = 360 TabIndex = 2 Top = 1440 Width = 1455 End Begin VB.TextBox databaseName Height = 285 Left = 360 TabIndex = 1 Top = 600 Width = 1455 End Begin VB.CommandButton StartTest Caption = "Start Test" Height = 615 Left = 2280 TabIndex = 4 Top = 720 Width = 1575 End Begin VB.Label pwtext Caption = "Password" Height = 375 Left = 360 TabIndex = 6 Top = 2040 Width = 1335 End Begin VB.Label Usertext Caption = "UserName" Height = 255 Left = 360 TabIndex = 7 Top = 1080 Width = 1095 End Begin VB.Label Label1 Caption = "Database name" Height = 255 Left = 360 TabIndex = 0 Top = 240 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim connection1 As ADODB.Connection Dim oRs As ADODB.Recordset Dim oField As ADODB.Field Dim sSQL$ Dim strPATH$ 'Const strDB_NAME As String = "flightstats" 'Const strDB_COPY_NAME As String = "flightstats2" 'Const strUSER As String = "root" 'Const strPASSWORD As String = "mypass" Const strTempFile As String = "Temp.txt" Private Sub quit_Click() Unload Me End End Sub Private Sub StartTest_Click() Dim strDB_NAME, strPASSWORD, strUSER As String strDB_NAME = [databaseName] strPASSWORD = [password] strUSER = [userName] strPATH$ = App.Path Set connection1 = New ADODB.Connection Set oRs = New ADODB.Recordset Dim strConnect$ strConnect$ = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;" & _ "DATABASE=" & strDB_NAME & ";USER=" & strUSER & ";PASSWORD=" & _ strPASSWORD & ";OPTION=3;" connection1.Open strConnect$ sSQL = "SELECT * FROM test_table" & _ " WHERE name LIKE 'EAA%'" ' This also fails on the same record 'sSQL = "SELECT * FROM test_table" ' But this statement will work 'sSQL = "SELECT * FROM test_table LIMIT 3" ' This statement will fail on the second dataset 'sSQL = "SELECT * FROM test_table2" & _ " WHERE name LIKE 'AMBER AIRPLANE%'" ' But This statement will work 'sSQL = "SELECT * FROM test_table2" & _ " ORDER BY name LIMIT 9" oRs.CursorLocation = adUseClient oRs.Open sSQL, connection1, adOpenStatic, _ adLockBatchOptimistic, adCmdText WriteToFile Set oRs.ActiveConnection = Nothing oRs.Close Set oRs = Nothing connection1.Close Set connection1 = Nothing End Sub Function WriteToFile() Dim strFileName$ Dim objFSO As New Scripting.FileSystemObject Dim objStream As Scripting.TextStream strFileName = strPATH & "\" & strTempFile ' Open the file and write the field data to it. Set objStream = objFSO.OpenTextFile(strFileName, _ ForWriting, True) oRs.MoveFirst ' print field names For Each oField In oRs.Fields objStream.Write oField.Name & "," Next objStream.Write vbCrLf 'print field data Do Until oRs.EOF For Each oField In oRs.Fields objStream.Write oField.Value & "," Next objStream.Write vbCrLf oRs.MoveNext Loop objStream.Close ' objStream = Nothing End Function Private Function ReadFile() End Function