Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Connection to MySQL using VBA

You can edit the code as required. if you changed the location or name of
the data source you'll have to edit the code.

" wrote:

Hi,

I have been using Excel to connect to a Simply Accounting SDB
database. Now I switch to 2009 which uses MySQL. The connection method
that I have been using doesn't work anymore. Appreciate if someone
could show me how to do it. The way I have been using is like this:

sDSN = "Simply Accounting: TestDB"
With ActiveSheet.QueryTables.Add
(Connection:="ODBC;DATABASE=TestDB;UID=john;PWD=12 34;DSN=" & sDSN,
Destination:=Range("A1"), Sql:=sSQL)
.FieldNames = bFieldname
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.PreserveColumnInfo = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With


Is it possible to just change the connection string?

Thanks
David

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
xls to mysql blitzburrgh Excel Discussion (Misc queries) 0 March 10th 08 04:01 PM
always recheck data connection library for latest connection strin FurmanGG Excel Discussion (Misc queries) 0 September 14th 07 04:48 PM
calling all pro's!!! macro that can modify dates in odbc connection to mysql majestik Excel Programming 1 September 10th 05 07:21 PM
Connection to MySQL causes "Catastrophic failure" Flemse Excel Programming 3 January 11th 05 12:19 PM
connection to internet mysql-database masterphilch Excel Programming 4 January 2nd 05 06:42 PM


All times are GMT +1. The time now is 12:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"