LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Database connection with LabSQL

In my Application,I use the LabSQL which connected to SQLServer.but it should build the DSN out of the application,I want to know if create the DSN in the application ,what should I do ?
In the LabSQL ,what should be written in the "connection string " for the "ADO Open connection" ?
Thanks in advance!
0 Kudos
Message 1 of 21
(7,197 Views)
hello

The DSN connection you need to create by yoursef (unless you want to use *.udl, than you can do it on fly).

It is the best to use a ODBC connection manager (in control pannel -> administrative tools) and there create a necesary DSN. The best way for you is to create a system DSN. You press "add.." button and follow the instructions on the screen. You need to choos the ODBC provider, could be MS SQL server, or simply MS access with Jet4 engine. Afterwards you save your DSN and you can easily use it in your application.
Rememebr however, that the same operation you need to do on every machine you are going to run your application on.

hope it helps
Pawel
0 Kudos
Message 2 of 21
(7,183 Views)
Thanks Pawel!
First,I know what you means!But I don't want operate the same operation on every machine,can I build the application Which contain the establish of the DSN?
Can I realize it?Thanks again !
0 Kudos
Message 3 of 21
(7,178 Views)
Hi again

OK, I need some answers from you:

1. What kind of database are you going to use? Access, MS SQL server.....

2. Does your LabSQL accept UDL (univeral data link) instead of DSN?

If you use a descent sql database, like provided by MS SQL server, you need to build a system ODBC as I described earlier.
If you use Access database, you can create UDL "on fly".

cheers
Pawel
0 Kudos
Message 4 of 21
(7,172 Views)
check out this link:

http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=B123AE0CBBF0111EE034080020E74861&p_node=DZ52046&p_submitted=N&p_rank=&p_answer=&p_source=External

-Joe
0 Kudos
Message 5 of 21
(7,163 Views)
Hey I was attempting to do a simliar feat. I have set up a system DSN using the ODBC adminstrator to connect to my external mySQL server (across the Internet). My current method to use the Open DB connectivity VI is to use set prompt = true and manually enter the information reffering to my system DSN. Is there another way to point to this DSN (ideally w/ prompt = False)?

Thanks, Corey

P.S. LV version 7.1 on WinXP

Side note: the connection through the prompt is not quite working yet. The MySQL server is denying me access but I have a feeling it is an issue of how I am passing the login/pass data.
0 Kudos
Message 6 of 21
(7,148 Views)
cdh wrote:

> Hey I was attempting to do a simliar feat. I have set up a system DSN
> using the ODBC adminstrator to connect to my external mySQL server

(across the Internet). My current method to use the Open DB connectivity

VI is to use set prompt = true and manually enter the information reffering

to my system DSN. Is there another way to point to this DSN (ideally w/
prompt = False)?

Well LabSQL uses ADO and I assume you use the myODBC driver to connect
trough ADO to mySQL. As such you are ultimately going through the ODBC
manager at some point and the ConnectionString property of the
Connection object can define all the settings an ODBC user would specify
to connect.

At
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdrefodbcprovspec.asp

the syntax of the ConnectionString is defined. If you set this property
of the Connection refnum before you issue the Open method call and leave
the parameters of the Open call all empty the connection will be made
with the parameters from the connection string. In addition to any ODBC
driver specific attributes you can define following attributes in the
connection string:

"[Provider=MSDASQL;] { DSN=name | FileDSN=filename } ;
[DATABASE=database;] UID=user; PWD=password"

The provider attribute can be omitted since this is the default ADO
provider.

Alternatively you can skip the entire DSN setup by specifying directly
all necessary parameters as attributes:

"[Provider=MSDASQL;] DRIVER=driver; SERVER=server;
DATABASE=database; UID=MyUserID; PWD=MyPassword"

Just add myODBC specific attributes to the end of these strings if
necessary.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 7 of 21
(7,135 Views)
Another thing you can do is programmatically create the DSN by using the Windows Registry Access VIs. If you look in your Registry under HKLM\SOFTWARE\ODBC\ODBC.INI, there should be a list of some already defined DSNs. You can use Registry Access VIs to create another DSN that points to your database. Then, from the Open Connection, you can specify the DSN you just created.
Jeremy L.
National Instruments
Message 8 of 21
(7,134 Views)
Thanks everybody for your answers.
Hello Pawel
1.I'am going to use the database of MSSQLServer.
2.The LabSQL which I use does't accept the URL.
If I use the MS SQLServer,I must build a system ODBC
as you described earlier?
Can you have another method to solve the problem?
Thanks again.
ying
0 Kudos
Message 9 of 21
(7,126 Views)
Hello Again

I think that Jeremy from NI gave you the very elegant way to do it.
If you have more problems, post it on this thread.

cheers
Pawel
0 Kudos
Message 10 of 21
(7,109 Views)