LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How it's possible to add ODBC source to windows resources?

Hi.

I'm using DB Connectivity Tools and MS Access Driver to connect to the database. My VI reads previous created data link. My problem is that I need do EXE file, and doesn't know how I can set the ODBC source in Windows directly in LabView, and create Datalink direct in LV (without using Tools->Create Data Link). Maybe somebody knows how to do this. Thanks in advance.

Message 1 of 8
(4,017 Views)
"Czaro" <x@no.email> wrote in message
news:1235418011432-858521@exchange.ni.com...
> Hi.I'm using DB Connectivity Tools and MS Access Driver to connect to the
database. My VI reads previous created data link. My problem is that I need
do EXE file, and doesn't know how I can set the ODBC source in Windows
directly in LabView, and create Datalink direct in LV (without using
Tools-&gt;Create Data Link). Maybe somebody knows how to do this. Thanks in
advance.

I'm not using the DB Connectivity Tools, so I can't help with that...

I usually create an ODBC connection with an API call. SQLConfigDataSource in
odbccp32.dll.

It has 4 inputs, hWND (set to 0), function (set to 4), driver (name of the
driver) and commandsstring (something like "DNS=databasename DBQ=filepath
UID=user PWD=password". Search the msdn or internet for details.

I'm sure there is a .NET or COM method to do this as well.

Regards,

Wiebe.


Message 2 of 8
(3,997 Views)

Help for your advice. It's very helpful.

So now, I'm trying to use odbccp32.dll, but it doesn't work. When I run the VI the ODBC sources don't change. Probably I do somethink wrong. I put a part of my VI to the JPG attachment.

0 Kudos
Message 3 of 8
(3,983 Views)
In the last string, don't seperate each parameter. Simply put a space
between two of them, not the quotes and \0. The \0 on the end is
automatically added by LabVIEW, so there is no need for that as well. Like I
mentioned, it should look like this: "DNS=databasename DBQ=filepath UID=user
PWD=password", where the quotes are not in the string. Perhaps the file path
needs quotes, if it contains spaces, but I don't think I use them, and it
works fine.

Regards,

Wiebe.


0 Kudos
Message 4 of 8
(3,976 Views)
I'm trying still, and it isn't any positive effect. Maybe the function call I have wrong? Or my operating system blocked action (Vista). The VI in the attachment doesn't add the DB to ODBC.
0 Kudos
Message 5 of 8
(3,969 Views)
Yes, in VISTA the application must be started as administrator! Sorry,
forgot about that. So, in your case, start LabVIEW.exe or the build app as
administrator.

Regards,

Wiebe.


0 Kudos
Message 6 of 8
(3,963 Views)

Wiebe@CARYA wrote:
In the last string, don't seperate each parameter. Simply put a space
between two of them, not the quotes and \0. The \0 on the end is
automatically added by LabVIEW, so there is no need for that as well. Like I
mentioned, it should look like this: "DNS=databasename DBQ=filepath UID=user
PWD=password", where the quotes are not in the string. Perhaps the file path
needs quotes, if it contains spaces, but I don't think I use them, and it
works fine.

Instead of creating a DSN you can also simply pass those parameters to the "connection string" parameter of the DB Tools Open Connec (String).vi.

 

Rolf Kalbermatter

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 7 of 8
(3,951 Views)

Can u send the program.I created a mdb file using create mdb vi,i attached.

 

Then i create system dsn in ODBC through control panel.how to do it programatically as like create mdb vi?

kavi
0 Kudos
Message 8 of 8
(3,690 Views)