LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Database connection with LabSQL.

Hi, I want to write a database application with LabSQL.
As with any database application on Windows, you'll need to create as DSN (Data Source Name) in the ODBC control panel. This DSN is used in your LabVIEW application to connect to appropriate database. But is it possible to make this connection programmaticaly in LabVIEW?
Davy
0 Kudos
Message 1 of 7
(3,830 Views)
If you mean can you create a DSN programatically in LV, the answer is probibly no--or at least not directly. Why do you need to create a DSN on the fly?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 7
(3,830 Views)
I believe that all it requires is an update to the registry. Using the ODBC administrator to create a System DSN adds a new entry to HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI. A User DSN gets created in HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.INI. The entries for a specific database type are different so what you need to add will depend on whether it's for an Access, SQL Server, Oracle, etc. database. To get a list of installed drivers, you can look at HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI. Microsoft's web site is the best place to get detailed information on ODBC and the registry.
0 Kudos
Message 3 of 7
(3,830 Views)
Davy wrote in news:5065000000080000003E8C0000-
1042324653000@exchange.ni.com:

> Hi, I want to write a database application with LabSQL.
> As with any database application on Windows, you'll need to create as
> DSN (Data Source Name) in the ODBC control panel. This DSN is used in
> your LabVIEW application to connect to appropriate database. But is it
> possible to make this connection programmaticaly in LabVIEW?
> Davy

You don't need a defined DSN. (At least i manage without it.)


The The following string is my "Connection string" for the "ADO Open
Connection"

------- Connection string for PostgreSQL ------------------------
Provider=MSDASQL.1;Extended
Properties="DRIVER={PostgreSQL};SERVER=ServerName;UID=UserName;PWD=Password
;READONLY=0;DAT
ABASE=DatabaseName"
-------- End --------------------------

------- Connection string for PostgreSQL ------------------------
Provider=MSDASQL.1;Extended Properties="DRIVER={Microsoft ODBC for
Oracle};SERVER=ServerName;UID=UserName;PWD=Password;"
------- End ---------------------------

Remark: Connection strings is wrapped, they should be without newlines.

The biggest problem is to find the DRIVER name. It seems that it is the
same as name in the Drivers tab on ODBC data source administrator.

Which other parameters to use may also be a little tricky to find out, but
i have some tools i experiment with.

--
Rolf
0 Kudos
Message 4 of 7
(3,830 Views)
Thanx Rolf, but it's not all clear to me. I am using an Access Database. I tried the following connection string:
----Start----------------------------------------------
Provider=MSDASQL.1;Extended Properties="DRIVER={Microsoft Access Driver}"
----End------------------------------------------------
But this is not working. What did you fill in for the other parameters. Can you maybe give some more examples?
Davy
0 Kudos
Message 5 of 7
(3,830 Views)
Davy wrote in message news:<50650000000500000095F90000-1042324653000@exchange.ni.com>...
> Thanx Rolf, but it's not all clear to me. I am using an Access
> Database. I tried the following connection string:
> ----Start----------------------------------------------
> Provider=MSDASQL.1;Extended Properties="DRIVER={Microsoft Access
> Driver}"
> ----End------------------------------------------------
> But this is not working. What did you fill in for the other
> parameters. Can you maybe give some more examples?
> Davy

This connection string works for me...
"
Mode=ReadWrite|Share Deny None;
Provider=Microsoft.Jet.OLEDB.4.0;
Persist Security Info=False;
Data Source=C:\database.mdb;
"
Victor
0 Kudos
Message 6 of 7
(3,830 Views)
victor@kbioscience.co.uk (Victor) wrote in
news:fc6650f8.0306040439.76f8cef0@posting.google.com:

> Davy wrote in message news:<50650000000500000095F90000-
1042324653000@exchange.ni.com>...
>> Thanx Rolf, but it's not all clear to me. I am using an Access
>> Database. I tried the following connection string:
>> ----Start----------------------------------------------
>> Provider=MSDASQL.1;Extended Properties="DRIVER={Microsoft Access
>> Driver}" ----End------------------------------------------------
>> But this is not working. What did you fill in for the other

>
> This connection string works for me...
> "
> Mode=ReadWrite|Share Deny None;
> Provider=Microsoft.Jet.OLEDB.4.0;
> Persist Security Info=False;
> Data Sourc
e=C:\database.mdb;
> "
> Victor

That one works for me too.

I also have another one:

---- Start ----
Provider=MSDASQL.1;
Extended Properties="
DRIVER={Microsoft Access Driver (*.mdb)};
DBQ=E:\db1.mdb;
DriverId=281;
FIL=MS Access;
MaxBufferSize=2048;
PageTimeout=5;
UID=UserName;
PWD=Password;"
---- End ---
Remark: The " are matching

MaxVufferSize, PageTimeout, and maybe some of the others are not necessery.
I made the connection string with help of the Datbase Viewer which follows
TestStand.

One thing i found out was that it seemed that i had problems with the UID
and PWD the first time but when i got it working i could put anything for
those parameters.

--
Rolf Østvik
0 Kudos
Message 7 of 7
(3,830 Views)