How to connect ms excel-2007 with mysql

0 votes
Establishing a MySQL connection with excel 2007. On Windows 7, 64-bit, I'm using. using MySQL 5.1 32-bit with excel 2007 32-bit. How can I import the data from my MySQL table into an Excel file?
Dec 22, 2022 in Others by Kithuzzz
• 38,010 points
322 views

1 answer to this question.

0 votes

Try this:

Function runQuery()
Dim cn As Object
Dim rs As Object
Dim strSql As String
Dim strConnection As String

Set cn = CreateObject("ADODB.Connection")

'Set your DB particulars
strConnection = "Data Source=MySQLExcel;Driver={MySQL ODBC 5.5.25a Driver};Server=" & _
                "localhost" & ";Database=" & "your-db-name" & _
                ";Uid=" & "your-user-name" & ";Pwd=" & "your-password" & ";"

    cn.Open strConnection
'Set your MySql query, i used "Select" query
    strSql = "SELECT * from Table-Name;"

    Set rs = cn.Execute(strSql)

'In case of "Select query" set your range to show records
'In case of "insert/edit/delete query" exclude next two lines
    Worksheets("SearchResults").Range("a4:xfd1048576").ClearContents
    Range("b4").CopyFromRecordset rs

'close the connection
    rs.Close
    Set rs = Nothing
    cn.Close
    Set cn = Nothing
answered Dec 23, 2022 by narikkadan
• 63,420 points

Related Questions In Others

0 votes
1 answer

How to open .xlsx files in MS Excel from VS Code?

Hello, to open xlxs files, or files ...READ MORE

answered Feb 17, 2022 in Others by gaurav
• 23,260 points
3,097 views
0 votes
1 answer

How to create a drop-down in excel with custom values

You can accomplish that using code rather ...READ MORE

answered Sep 25, 2022 in Others by narikkadan
• 63,420 points
742 views
0 votes
1 answer

How to merge two cells in excel with same field name

Insert 2 new columns, G & H. Enter ...READ MORE

answered Oct 7, 2022 in Others by narikkadan
• 63,420 points
1,211 views
0 votes
1 answer

How Can I Round Prices to the nearest 0.95 with an Excel Formula?

Try this: =IF(OR(A3-FLOOR(A3,1)>0.95,A3=CEILING(A3,1)),CEILING ...READ MORE

answered Oct 9, 2022 in Others by narikkadan
• 63,420 points
471 views
0 votes
1 answer
0 votes
1 answer

Online Excel Web-based Platform

You can use any of the following ...READ MORE

answered Sep 24, 2022 in Others by narikkadan
• 63,420 points
331 views
0 votes
1 answer
0 votes
1 answer

Online MYSQL editor as an Excel-like spreadsheet

That depends on who are those users, ...READ MORE

answered Oct 8, 2022 in Others by narikkadan
• 63,420 points
753 views
0 votes
1 answer

How to get the JasperReports into Excel format with proper alignment

Remove at least one parameter: exporter.setParameter(JRXlsExporterParameter.IS_COLLAPSE_ROW_SPAN,Boolean.TRUE) Note that JRXlsExportParameter is deprecated the correct ...READ MORE

answered Sep 21, 2022 in Others by narikkadan
• 63,420 points
3,152 views
0 votes
1 answer

How to print an Excel Sheet using VBA with Nitro PDF Creator in Excel 2016

you can use the built-in excel facilities ...READ MORE

answered Sep 24, 2022 in Others by narikkadan
• 63,420 points
869 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP