LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Is SQL Connection Function or API Availble in SQL Toolkit 2.2 (Urgent) ?

Solved!
Go to solution

Hello,

I have build an application using LabWindows 2010 and SQL Toolkit 2.2. Is there any function or dll or api availble so that i do not want to make connection in control panel ODBC ?.

 

Regards

Umer

0 Kudos
Message 1 of 16
(5,528 Views)

Hello,

 

The manual for this toolkit might be a good reference for you: LabWindows/CVI SQL Toolkit Help

There is a function called DBConnect, which allows you to connect to a database programmatically. The Help says:

"Purpose: Opens a to a database system to allow execution of SQL statements. Calling DBConnect is equivalent to calling DBNewConnection and then DBOpenConnection"

 

There's also a page in the help titled Connecting to a Database, which tells you more information about how to use DBConnect:

"Use DBConnect to connect to a data source. The only parameter is a connection string, which must contain the data source or provider name and any other attributes the database requires. DBConnect returns a handle to the database connection that other functions in the toolkit use. Call DBDisconnect to close the database connection, passing in the database connection handle from DBConnect. The following code is a simplified version of the code found in connect.prj.

 

int hdbc = 0; /* Handle to database connection. */
int rescode; /*Result code. */
/* Connect to CVI_Samples data source. */
hdbc = DBConnect ("DSN=CVI Samples");
if (hdbc <= 0) goto Error;
...
/* Disconnect from database. */
resCode = DBDisconnect (hdbc);
if (resCode != DB_SUCCESS) goto Error;
"

 

Hope this helps.

Taylor B.
National Instruments
0 Kudos
Message 2 of 16
(5,495 Views)

Hello

First Thanks to reply,

I am using Window XP operating system and i am using the following two function for connect and disconnect database as you have mention above.

===========================================================================

int DatabaseConnect(void)
{
handle_database = DBConnect("DSN=RADSdb");

if(handle_database<=0)
{
MessagePopup("Database Error",DBErrorMessage());
return -1;
}
return 0;
}

===========================================================================

int DatabaseDisconnect(void)
{
int result_code=0;
result_code = DBDisconnect(handle_database);
if(result_code !=DB_SUCCESS)
{
MessagePopup("Database Error",DBErrorMessage());
return -1;
}
return 0;
}

===========================================================================

But the problem is other when i re-install window or make new user account window my application popup database connection fail popup. i have to make connection on windows control panel ODBC. When this step is done the application working fine.

 

Regards

Umer

0 Kudos
Message 3 of 16
(5,491 Views)

I'm not sure what you mean about reinstalling the window. Is this a user interface (UIR file) that you have created, or is this something you're using with the database? It would help if you could clarify the issue, maybe with code snippets or screen shots.

Taylor B.
National Instruments
0 Kudos
Message 4 of 16
(5,481 Views)

Hello Umer,

you described a common need, that I have already pointed to NI attention (without success, unfortunately)

when I work on my development machine, I can go into control panel >> ODBC and create items.

But when I distribute my application to customers, it's not acceptable to ask them to do such a kind of configuration.

 

For this reason I don't use the connection string "DSN=....", but the proper connection string I find in http://www.connectionstrings.com/ (it depends on the database I want to connect to)

 

I've already write to NI that they should change the SQL Toolkit help and example and replace "DSN=..." with these direct connection strings.

I think DSN should be deprecated.

 

I found that SQL Toolkit 2.2 has some bugs (confirmed by NI) when you use direct connection strings (not when you use DSN), but I've been still waiting for the bug fixing for years

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 5 of 16
(5,475 Views)

Hello Taylor,

when Umer writes "reinstall Windows" he means a whole installation from scratch of Windows operating system

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 6 of 16
(5,471 Views)

Hello Vix,

I've read your post and would like to have some detail more.

I'm now developing an application for a customer of mine which makes use of the SQL toolkit: can you describe the problems you have found or point me to some document/forum thread that describe them?

Thank you.

 

BTW I suppose what you say about the connection string in DBConnect applies as well to DBNewConnection + a bunch of DBSetConnectionAttribute + DBOpenConnection.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 7 of 16
(5,469 Views)

Hello Roberto,

do you need some details about connection strings or about SQL Toolkit bugs?

Or about both of them?

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 8 of 16
(5,466 Views)

I'm really interested into bugs and unsolved problems.

For the moment I will create and use a DSN so that I have no real problems in connection: my question on connection was only dictated by curiosity.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 9 of 16
(5,456 Views)

Here are the bugs I found (discussed through private support channel):

  • DBTables (hdbc,"","","", DB_TBL_TABLE);                        - even objects that aren't tables are fetched
  • DBTables (hdbc,"","","", DB_TBL_TABLE | DB_TABLE_VIEW);        - right syntax (according to help), but gives "Unknown flag value"
  • DBMapColumnToDouble (hmap, "MEAS1", &meas1, &meas1Stat);            - the following DBCreateTableFromMap() creates a column called "MEAS1" (I mean the quotes are part of the name of the column)
  • using DBCreateParamChar() to pass an empty string "" gives an error                - no way to pass empty strings to stored procedures
Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 10 of 16
(5,448 Views)