top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to write Macro for mysql?

0 votes
302 views
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;")), _
        Destination:=Range("$A$1")).QueryTable
            .CommandText = Array("Select * FROM <TableName>")
            .RefreshOnFileOpen = True
            .BackgroundQuery = True
            .RefreshStyle = xlInsertDeleteCells
            .SavePassword = True
    End With
End Sub][1]

http://answers.microsoft.com/en-us/office/forum/office_2003-customize/macro-query-mysql-database-with-dsn-less/7a7a4b22-7cb1-4ef2-8007-d8c6d2689947

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:

"INCORRECT STRING VALUE: \'XE2X9CX93"X0A ...\' FOR COLUMN \'HANDLER\' AT ROW 1"

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.

...