LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Select Database Path via labview

Solved!
Go to solution

Hello gurus...........
    I am new user in labview. I want read and write in database through labivew . I have
done read and write program. Now I want choose database storage path through labview .
I tried differnt ways but I couldn't.
First read and write program i did via UDL file path .Now i want Directly choose ".mdb" file path.

I dont know how to do ......
So if you know please help me.....
Thanks advance

Regards
Arunkumar M
India

0 Kudos
Message 1 of 10
(4,312 Views)
What you need to do is modify the connect string that is contained in the udl. What database drivers are you using? The drivers I wrote always use a connect string because in the long run its a lot more convenient. If you are using the DCT there is a way to.connect string rather than a UDL.

To see what the connect string currently is, open the UDL file with notepad. The place to insert the path should be obvious.

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
(4,199 Views)
What can be very useful is having the connect string in an ini file that gets loaded at the beginning.
0 Kudos
Message 3 of 10
(4,153 Views)

Yeah, as the others have said - use the connection string rather than path to a connection file.

 

What I actually do is store the server/database/username/password in a file and then use format into string to build my connection string as it makes it slightly more user friendly to change the configuration file.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 4 of 10
(3,995 Views)

Thanks for all replies. but how I give to connection string . I was searching labview but i could not find that option. If you give image file I will make easy . I am using Labview2014 Evaluation version. And using Database connectivity tool kit.

 

This is my What exactly I want to do......

 

I want save my database (MS access) file any where in my system . When I want change my storage path that time i want to change during running mode (Not a UDL file I want to change My .mdb file). 

 

I attached what did earlier.....

So please give possble way......

 

(sorry for my grammetical mistake) .

 

0 Kudos
Message 5 of 10
(3,983 Views)

I think the way the database connectivity toolkit works, it is expecting the database to already exist. The function you are calling creates a table so it probably errors if the file doesn't exist. If you google 'create access database programmatically' you may be able to find something useful for creating a new access database file. Don't forget that you also have the native File I/O functions in LabVIEW for copying/moving files on disk.

 

For the connection string...there's a handy website here: http://www.connectionstrings.com/

 

I think you can also open a connection file (UDL) in notepad?


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 6 of 10
(3,975 Views)
Solution
Accepted by topic author arun575

Rather than try to create an Access database, I've simply included an empty database with the installation.  Open it, build the tables as required (as your example shows) then copy it (using Copy from the Advanced File I/O palette) to wherever you need it.  Your program will need to know where it is, so storing the connection information in a configuration file (as already mentioned) is a possibility.

 

Here's how to use a connection string to open a database:

Database create_BD.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 7 of 10
(3,901 Views)

Thanks for all.......
Finally i Got the solution......

Thanks
Regards

Arunkumar M
India

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

Hello jcarmody,

I have a question regarding your solution. Please pardon that I am posting on a thread that goes 4 years back.

What exactly happends when I open the database the way you suggested? Does a system DSN get created in the system register every time the database is opened this way?

Appreciate your reply.

 

 

0 Kudos
Message 9 of 10
(2,747 Views)

No! Look at the DSNs like a telephone directory. You tell the Open Database function to simply lookup the according DSN and use the stored information in that DSN to create a connection. If you have an UDL file instead it is like a business card that contains all the necessary information to create this single connection. Or you pass the Open Database function all the necessary information to create a connection, which is what that example does.

When you create a DSN entry the ODBC database configuration tool lets you select a DB provider, then invokes a special interface in that provider that shows you the configuration options. At the end these configuration options are all stored in the registry under the DSN name with a connection string. When you pass a DSN name to the Open Database connection, it looks up the DSN in the registry, retrieves the connection string and uses that to intialize the connection. Instead you can directly format your own connection string and pass it to the Open Database function. The entire DSN business is then completely left out of the whole.

The difficulty is to know what to put in the connection string. The first option that defines the DB provider(driver) is always "Provider=<some name>". After that follow the options which are provider specific as each database driver uses its own settings. Some are network connected databases and need a network address, others use a local database file and therefore need a path, and there can be several other parameters that the driver may need to work properly and also of course optional parameters like timeouts, and many others.

There are many sites that give you thousends of possible connection strings for all kind of databases, yet they often lack both the information for which version of the database driver they are (the connection strings can vary significantly depending on the version) as well as an explanation what the different settings actually mean, and copy and paste verbatim seldom works.

A better way is to create your own UDL file with the ODBC configuration tool and then open that in a text editor to get an idea what settings are needed for your specific database. Then you can use the contents of that file  as connection string and adapt some of the settings such as the actual local db file path.

Rolf Kalbermatter
My Blog
Message 10 of 10
(2,745 Views)