top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

How to write Macro for mysql?

0 votes
How to write Macro for mysql?
posted Aug 3, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Create a Macro that creates a TableQuery. You only need to do this once. Once the table is setup, the connection stays saved in the file.
Here is the general code I used for the Macro in Excel (you need to replace the with your actual values, without the brackets):

[Sub DSNLess_Connection ()
Dim dSource As String
dSource = "ODBC;DRIVER={MySQL ODBC 5.1 Driver};" _
& " SERVER=<server name>;DATABASE=<database name>;" _
& " UID=<user name>;PWD=<strong password>;Port=3306"
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array(Array( _
        dSource), Array("E=db35211_CustomerMasterList;DefaultTable=Customers;")), _
            .CommandText = Array("Select * FROM <TableName>")
            .RefreshOnFileOpen = True
            .BackgroundQuery = True
            .RefreshStyle = xlInsertDeleteCells
            .SavePassword = True
    End With
End Sub][1]

answer Aug 9, 2014 by Vrije Mani Upadhyay
Similar Questions
+1 vote

I need to select some data from a table where a column is not a numerical value but can't seem to get the right syntax for this.

Basically we need to do something like this:

SELECT * FROM tablename WHERE column_name (IS NOT A NUMERIC VALUE)

what is the correct syntax to accomplish this?

+1 vote

Is there a way to make python script that connects to mySQL DB ask for a password on the:

conn = mdb.connect(host, user)
+1 vote

Assume there is one database in a system having multiple processes that are accessing this database.
If one process updates database table other processes should be notified. If someone has MySql C APIs document please send me.
Thanks in advance.

+2 votes

I have a rails application, in which I am using delayed_job_active_record gem for running background jobs. While using the method .delay with an object, I am getting the following mysql error:


I already searched for the above error and found that its because of the difference in encoding in mysql and rails. The solution suggested by many programmers is to alter the encoding in mysql database to utf8. But I also read that MySQL's utf8 charset only partially implements proper UTF-8 encoding. It can only store UTF-8-encoded symbols that consist of one to three bytes; encoded symbols that take up four bytes aren't supported. Which might cause trouble in some other cases. Also, when I tried to insert the value directly in mysql, it worked like a charm. Suggesting that the issue might lie elsewhere. So, can anyone please suggest the right method to rectify this problem?

Any help would be greatly appreciated.

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.