LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

create SQL server data source programmatially

Solved!
Go to solution

Hi,

I'd like to create a SQL server data source programmatically in LabVIEW. The SQL server version I used is 2005. Can anyone give some ideas? A code example will be most favorable.

Thanks,

Jane

0 Kudos
Message 1 of 10
(3,772 Views)
What do you mean by creating a data source. Do you mean creating a database? Defining the connection string?

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 10
(3,760 Views)

A system DSN...

0 Kudos
Message 3 of 10
(3,756 Views)

You don't need a system DSN (.dsn or .udl file) to connect to a database.

Assuming you're using the DB Connectivity tooolkit, you can pass a connection string to DB Tools Open Connection.vi.

The connection string can directly contain the DB path, driver to use, credentials and other parameters.

Just create a connection string similar to the contents of a .udl file.

 

0 Kudos
Message 4 of 10
(3,741 Views)
Dan put it well. All you need is a connection string and those are easy to build. There are even a couple website that do nothing but publish template connection strings for every DBMS on the planet.

The only point I would quibble over is about using the database connectivity toolkit. The DCT is an unnecessary complication that is ultimately counter productive because it limits your support options. When I get into the office in a few hours I will post a link to an alternative that actually simplifies the process and is free.

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 5 of 10
(3,736 Views)
Oh yes, if you want to see the contents of a udl all you have to do is change its file extension from udl to txt and open it with notepad.

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 6 of 10
(3,734 Views)

Here is the link I promised, it provides a lot of good discussion and information, as well as some very good drivers that don't need the DCT.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

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

For help with grief and grieving.
Message 7 of 10
(3,724 Views)
Solution
Accepted by topic author Jane.Yu

You can build the connection string yourself.  The Open function in the database toolkit accepts a string as well (it's polymorphic) which can be the connection string.  This is the website I use to figure it out.  Is has most common stuff.  You may have to search Google some more for specific items.

 

http://www.connectionstrings.com/

 

If you want to use the other option, someone has made a UDL editor in LabVIEW.  You can use this code to create your own UDL which the DB Open function can use:

 

https://decibel.ni.com/content/docs/DOC-18613

 

I have used the above code, so cannot comment on it.

0 Kudos
Message 8 of 10
(3,718 Views)

That UDL editor is cool, but there is also one built into Windows.

 

  1. On desktop create empty text file.
  2. Change the file extension from .txt to .udl
  3. Double-click the file and behold the editor. When you are finished and have tested the setup, save your work and close the editor.
  4. Change the file extension from .udl back to .txt
  5. Double-click the file to open it with notepad, and behold your connection string.

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 9 of 10
(3,711 Views)

#4 is unnecessary if you have some decent text editor lite Textpad, Notepadd++ or similar installed, then you always have Edit it Notepad++ on the r-click menu. 🙂

 

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 10
(3,684 Views)