Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Pulling data from mySQL DB to Excel spreadsheet

I know it can be done, but I have no clue where to start. I need to pull data
from several mySQL DB's into Excel. Can anyone point me in the right
direction?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Pulling data from mySQL DB to Excel spreadsheet

Google this: excel vba connect to mysql db

"neu2me" wrote:

I know it can be done, but I have no clue where to start. I need to pull data
from several mySQL DB's into Excel. Can anyone point me in the right
direction?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Pulling data from mySQL DB to Excel spreadsheet

All I'm seeing requires me to install drivers on the machines that will use
the eventual app... is there a way around that?

"Mike" wrote:

Google this: excel vba connect to mysql db

"neu2me" wrote:

I know it can be done, but I have no clue where to start. I need to pull data
from several mySQL DB's into Excel. Can anyone point me in the right
direction?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Pulling data from mySQL DB to Excel spreadsheet

Try this
'declare the variables
Dim Connection
Dim ConnectionString
Dim Recordset
Dim SQL

'declare the SQL statement that will query the database
SQL = "SELECT * FROM TABLE_NAME"

'define the connection string, specify database driver
ConnectionString= "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost;
DATABASE=Your_Mysql_DB; " &_
"UID=mysql_username;PASSWORD=mysql_password; OPTION=3"

'create an instance of the ADO connection and recordset objects
Set Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")

'Open the connection to the database
Connection.Open ConnectionString

'Open the recordset object executing the SQL statement and return records
Recordset.Open SQL,Connection

'first of all determine whether there are any records
If Recordset.EOF Then
Response.Write("No records returned.")
Else
'if there are records then loop through the fields
Do While NOT Recordset.Eof
Response.write Recordset("FIRST_FIELD_NAME")
Response.write Recordset("SECOND_FIELD_NAME")
Response.write Recordset("THIRD_FIELD_NAME")
Response.write "<br"
Recordset.MoveNext
Loop
End If

'close the connection and recordset objects freeing up resources
Recordset.Close
Set Recordset=nothing
Connection.Close
Set Connection=nothing

"neu2me" wrote:

All I'm seeing requires me to install drivers on the machines that will use
the eventual app... is there a way around that?

"Mike" wrote:

Google this: excel vba connect to mysql db

"neu2me" wrote:

I know it can be done, but I have no clue where to start. I need to pull data
from several mySQL DB's into Excel. Can anyone point me in the right
direction?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Pulling data from mySQL DB to Excel spreadsheet


"neu2me" wrote in message
...
All I'm seeing requires me to install drivers on the machines that will
use
the eventual app... is there a way around that?


You could host the SQL querying on a web server, creating a "web service"
which could be used to pull the data. That way you only have to install the
drivers on the server.

Tim



"Mike" wrote:

Google this: excel vba connect to mysql db

"neu2me" wrote:

I know it can be done, but I have no clue where to start. I need to
pull data
from several mySQL DB's into Excel. Can anyone point me in the right
direction?





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Pulling data from mySQL DB to Excel spreadsheet

Are there any specfic references I'll need in order to use this code?

"Mike" wrote:

Try this
'declare the variables
Dim Connection
Dim ConnectionString
Dim Recordset
Dim SQL

'declare the SQL statement that will query the database
SQL = "SELECT * FROM TABLE_NAME"

'define the connection string, specify database driver
ConnectionString= "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost;
DATABASE=Your_Mysql_DB; " &_
"UID=mysql_username;PASSWORD=mysql_password; OPTION=3"

'create an instance of the ADO connection and recordset objects
Set Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")

'Open the connection to the database
Connection.Open ConnectionString

'Open the recordset object executing the SQL statement and return records
Recordset.Open SQL,Connection

'first of all determine whether there are any records
If Recordset.EOF Then
Response.Write("No records returned.")
Else
'if there are records then loop through the fields
Do While NOT Recordset.Eof
Response.write Recordset("FIRST_FIELD_NAME")
Response.write Recordset("SECOND_FIELD_NAME")
Response.write Recordset("THIRD_FIELD_NAME")
Response.write "<br"
Recordset.MoveNext
Loop
End If

'close the connection and recordset objects freeing up resources
Recordset.Close
Set Recordset=nothing
Connection.Close
Set Connection=nothing

"neu2me" wrote:

All I'm seeing requires me to install drivers on the machines that will use
the eventual app... is there a way around that?

"Mike" wrote:

Google this: excel vba connect to mysql db

"neu2me" wrote:

I know it can be done, but I have no clue where to start. I need to pull data
from several mySQL DB's into Excel. Can anyone point me in the right
direction?

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
Pulling data from one spreadsheet to another. Geof Davies Excel Worksheet Functions 1 November 14th 09 01:46 AM
Pulling Data from one spreadsheet to another tryn''''2learn Excel Programming 2 May 1st 07 10:10 PM
Pulling data from multiple spreadsheet Mark C[_2_] Excel Worksheet Functions 2 February 27th 07 04:02 AM
Exported data pulling into another spreadsheet Bemidji Excel Discussion (Misc queries) 6 August 8th 06 03:58 PM
Please Help! - Need Help pulling data from one spreadsheet to anot dhwinters Excel Worksheet Functions 1 February 1st 06 09:20 PM


All times are GMT +1. The time now is 07:30 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"