MySQL Forums
Forum List  »  Newbie

Re: Export mySQL to Excel
Posted by: Bruce Bock
Date: November 19, 2008 10:58AM

I tried your code and made the changes that I thought were needed and I'm getting a Compile error: Syntax error on the line containing MySQLConn.Close() any ideas on why it does not like this. Multiple examples on searching Google show this statement.



Public Sub Import()
' connect to the Asterisk db, with UID/PWD and select all records from table and place the contents of the recordset into Excel...

Dim MySQLConn, sqlstr, MySQLRS
Set MySQLConn = CreateObject("ADODB.Connection")
MySQLConn.Open = "DRIVER={MySQL ODBC 5.1 Driver};SERVER=192.168.6.2;DATABASE=asterisk;UID=root;PWD=password;OPTION=35;"
sqlstr = "SELECT * FROM asterisk;"
Set MySQLRS = CreateObject("ADODB.Recordset")
MySQLRS.Open sqlstr, MySQLConn, 1, 4, 1

Dim Excel
Set Excel = CreateObject("Excel.Application")
Excel.Visible = True
Excel.Workbooks.Add
Excel.Workbooks(1).Worksheets(3).Range("A2").CopyFromRecordset MySQLRS


MySQLConn.Close()
Set MySQLConn = Nothing

End Sub

Options: ReplyQuote


Subject
Written By
Posted
October 31, 2008 03:48AM
October 31, 2008 08:13AM
Re: Export mySQL to Excel
November 19, 2008 10:58AM
November 19, 2008 12:16PM
November 19, 2008 12:40PM
November 19, 2008 03:38PM
November 20, 2008 04:07PM
November 20, 2008 04:22PM
December 02, 2008 04:47PM
December 02, 2008 09:19PM
December 03, 2008 10:00AM
December 03, 2008 11:13AM
December 14, 2008 10:19PM
October 31, 2008 08:35AM
November 01, 2008 05:01AM
November 01, 2008 07:39AM
November 01, 2008 02:18PM
November 02, 2008 12:09AM
November 02, 2008 07:00AM
November 02, 2008 08:59AM
November 02, 2008 10:57AM
November 02, 2008 12:44PM
November 03, 2008 09:42PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.