LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Connection String Syntax for labSQL to MySQL

Solved!
Go to solution

Hello all,

 

I am just getting started using labSQL and MySQL and can not even connect to the database I want to practice with. I have tried to write my own code and use the example code but I can not get a connection to any database. The error is always "Exception occurred in ADODB.Connection: Operation is not allowed when the object is closed.Help Path is C:\Windows\HELP\ADO270.CHM and context 1240653 in ADO Connection Execute.vi->Simple.vi". I set up a system DSN using the MySQL ODBC 5.2 Unicode Driver and I am running Labview 2012 with MySQL 5.2 Workbench/5.6 Server. I would really just like to know the syntax of the connection string you pass into the ADO Connection Open vi.

 

Thank you all in advance.

0 Kudos
Message 1 of 11
(5,116 Views)
0 Kudos
Message 2 of 11
(5,111 Views)

Thank you for the link. Now I just recieve a different error though. If I use any of the strings the link suggests (I use the ODBC 5.1 strings and just change them to 5.2) I get the error "Data source name not found and no default driver specified". So if I then specify the DSN it gives me the error " The specified DSN contains an architecture mismatch between the Driver and Application".  Other forums suggest setting up the DSN through a different application (C:\Windows\System32\obdcan.exe or C:\Windows\SysWOW64\odbcan.exe) but I can't find the same drivers then. I know my version of Labview is 32-bit but I don't know what the drivers are. Any suggestions?

0 Kudos
Message 3 of 11
(5,096 Views)

Can you post your current connection string?

 

This is what I use to connect to a local instance of MSSQL using the native client.  I've removed some relevant portions between the < and > brackets:

Provider=SQLNCLI10.1;Data Source=(local)\SQLExpress;server=(local);Initial Catalog=<LocalDBName>;User Id=<User>;Password=<Password>;

 The initial catalog can be set to Master to use the database that is created when installing MSSQL.

 

Obviously this is different from your MySQL situation, but hopefully the example gives you something to work from.

0 Kudos
Message 4 of 11
(5,092 Views)

I use two different strings. The first error message I listed seems to just be because I never named a DSN. I therefore enter one of the following two strings:

 

DSN=<DSN_name>;

or

DSN=<DSN_name>; Provider=MSDASQL; Driver={MySQL ODBC 5.2 Unicode Driver}; Server=localhost; Database=<database_name>; User=root; Password=<password>; Option=3;

 

Both give the second error message about the architecture mismatch.

0 Kudos
Message 5 of 11
(5,088 Views)

@McGillicuddy wrote:

I use two different strings. The first error message I listed seems to just be because I never named a DSN. I therefore enter one of the following two strings:

 

DSN=<DSN_name>;

or

DSN=<DSN_name>; Provider=MSDASQL; Driver={MySQL ODBC 5.2 Unicode Driver}; Server=localhost; Database=<database_name>; User=root; Password=<password>; Option=3;

 

Both give the second error message about the architecture mismatch.


Why are you writting your connection strings like that?

 

0 Kudos
Message 6 of 11
(5,081 Views)

What if you leave the Driver part out?

What if you leave the Option part out?

What if you leave the DSN part out?

What about the Driver and the DSN both out?

etc...

I think you're probably pretty close and might just need to experiment a bit.


Also I noticed you have spaces after the semicolons and I don't.  No idea if that would make a difference or not.

0 Kudos
Message 7 of 11
(5,080 Views)

How else would I write the connection string? I suppose that was a little misleading since each space is acually where a new line starts. 

 

As for changing which arguments I give it, only one option changes anything:

 

1) If I give it a DSN it complains about the architecture mismatch

2) If I don't give it a DSN it complains that I haven't given it a DSN

 

Thanks for all the help so far. I really feel like there is something strange going on with the bit versions of theses different things. My labSQL appears to be 64-bit? but I can't tell for sure. Any way to fix the mismatch error?

 

Thanks again for all the help.

0 Kudos
Message 8 of 11
(5,074 Views)

Mine is all on a single line.  You can resize the text box if needed.

0 Kudos
Message 9 of 11
(5,071 Views)

Tried it, doesn't make a difference.

 

I really just want help with the error message about the architecture mismatch. I have tried downloading a 32-bit version of MySQL but the installer doesn't give me a choice of which to install. Once I install it and go back it has the option, but then it won't let me since the 64-bit version is already installed.

0 Kudos
Message 10 of 11
(5,068 Views)