07-25-2015 03:52 AM
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
Solved! Go to Solution.
07-25-2015 12:12 PM
07-25-2015 03:10 PM
07-27-2015 03:23 AM
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.
07-27-2015 03:43 AM - edited 07-27-2015 03:43 AM
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) .
07-27-2015 03:48 AM
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?
07-27-2015 06:12 AM
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:
07-27-2015 07:29 AM
Thanks for all.......
Finally i Got the solution......
Thanks
Regards
Arunkumar M
India
05-08-2019 05:38 AM
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.
05-08-2019 06:06 AM - edited 05-08-2019 06:18 AM
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.