I am trying to import data from MYSQL database to excel Sheet but i am getting this error
{MySQL][ODBC 5.2(w) Driver][mysqld-5.6.16-log] you have an error in
your Sql syntax; check the manual that corresponds to your MYSQL
server version for the right syntax to use near 'FROM where FQR_User_Code='usman' and line_status in('QP')
order by line_status' at line 1
<code> 'Create the connectionstring.
strConn = "Driver=MySQL ODBC 5.2 Unicode Driver;" _
& "Data Source=" & stDB & ";"
'The 1st raw SQL-statement to be executed.
stSQL1 = "SELECT * FROM tblbatch_headers where idBatch " & batchID & "order by col_seq asc"
'The 2nd raw SQL-statement to be executed.
stSQL2 = "SELECT " & dataStr & " FROM " & prdTblName & " where FQR_User_Code='" & Application.username & _
"' and line_status in('QP') order by line_status"
'Clear the worksheet.
Sheet1.Range("A1").CurrentRegion.Clear
With cnt
.Open (strConn) 'Open the connection.
.CursorLocation = adUseClient 'Necessary to disconnect the recordset.
End With
With rst1
.Open stSQL1, cnt 'Create the recordset.
Set .ActiveConnection = Nothing 'Disconnect the recordset.
End With
With rst2
.Open stSQL2, cnt 'Create the recordset. it shows this line
Set .ActiveConnection = Nothing 'Disconnect the recordset.
End With</code>
Bookmarks