From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Connect to MySQL Server WITHOUT creating a Windows ODBC Connection

Solved!
Go to solution

Hi,

 

currently I am writing data from LabView to a MySQL server using an ODBC data source. Problem is (since now): I need the user to NOT be able to read my database. But everyone, who has access to the machine, should be able to just reference the ODBC data source (which I created for LabView) for any application and have access to my data, correct?

 

Is there a way to store my DB credentials somewhere safe (like "in the LabView code")? If so, how would I do that? I've heard about UDL files, but those are plaintext and have to be stored somewhere on the disk...

 

Thank you for any advice

Martin

0 Kudos
Message 1 of 6
(2,411 Views)
Solution
Accepted by topic author mw42

The Connection string that's stored in e.g. a .UDL can be wired directly to Open DB Connection.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 2 of 6
(2,382 Views)

So what you're saying is:

Create UDL File, open with editor, get content and paste into "string constant" in Labview ?

0 Kudos
Message 3 of 6
(2,377 Views)

Just as additional information, here is how it is working for me (of course, the MySQL ODBC driver has to be installed)

 

mw42_0-1597155907375.png

 

Addendum: It seems to be important to include "Option=3;" in the string for some reason (that is not in my picture)

Message 4 of 6
(2,354 Views)

Thank you. Your additional information helped me a lot.

0 Kudos
Message 5 of 6
(1,400 Views)

@mw42 wrote:

 

mw42_0-1597155907375.png

 


I don't know about MySQL specifically, but the VI shown in this image has inputs for the user ID and password which it passes to the ADO Open method, so it should certainly be possible to put the password in the VI and use a UDL (without saved credentials) to point to the relevant DB.

 

The big advantage of this is that you can then modify the UDL file or use another UDL file if you want to point to a different DB (e.g. a staging environment vs. production or a situation where you might have multiple servers).

 

Even if that didn't work, it would also have been possible to edit the connection string in code and have parts of it come from an external config file and parts of it be stored in the code.


___________________
Try to take over the world!
0 Kudos
Message 6 of 6
(1,382 Views)