LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

SQL connection problem

Solved!
Go to solution

I'm making some database functions using CVI SQL toolkit 2.3 (on Windows 7 & LW/CVI 2013)

The sample files (weather, flowchart......) are all working.

I tried to create my own mdb file, but the table and data are directed to samples.mdb of the sample files.

I specified the path in DBCreateTableFromMap, but not successful.

 

Please advise.

 

 

0 Kudos
Message 1 of 8
(3,597 Views)

Hey Hong Kong,

 

A couple of questions and points:

 

  • Could you provide more background on what exactly you're trying to do, and how you're trying to accomplish it? i.e. provide a copy of your database and code.
  • DBCreateTableFromMap() takes an integer mapHandle as the first argument, and then a char tableName as the second argument. You shouldn't be passing any paths into this function as arguments
  • Can you connect to your custom database using the DBConnect() function? If the database is an OBDC data source, you can use the DSN flag. Refer to the 'connect.cws' example for this implementation (Help >> Find Examples >> search 'sql')

Bdog

 

 

 

 

0 Kudos
Message 2 of 8
(3,558 Views)

Hi,

 

We just want to make a custom database file.  All functions are working (DBConnect, DBBeginMap, DBMapColumnToxxxx, DBCreateTableFromMap......).

 

The only questions is, the data is automatically saved to sample.mdb (the sample file of CVI SQL toolkit under the folder C:\......\CVI\Samples\sql), instead of our target file. 

 

May be there are some settings in Windows ODBC but we have no idea.

 

Please advise.

0 Kudos
Message 3 of 8
(3,552 Views)

Hi Hong_Kong,

 

Thanks for providing that context. The first step is to register your database. I copy and pasted the default 'samples.mdb' file into another location and renamed it:

 

file.JPG

Now, we have to register the database in the Microsoft ODBC manager. For this, in my Windows search I searched for 'ODBC Data Source Administrator' and opened 'ODBC Data Sources (32-bit)'. I then navigate to the 'System DSN' tab.

 

system dsn.JPG

 

Here, we have our registered Data Source Names (DSN). The 'CVI SQL Samples' should look familiar because that's what CVI has been calling. To register our database, click on 'Add' and select the 'Microsoft Access Driver (*.mdb)' option:

 

new DSN.JPG

 

Click 'Finish', and enter a Name and Description as shown below. The Name is how you will reference this DB in CVI and any other code. 

 

new customdb.JPG

Click 'Create' and enter a name for your custom .mdb file. 

 

new customdbname.JPG

Click 'OK' and now you should see your database appear under the 'System Data Sources':

new sys data sources.JPG

Now just connect to it from your code by replacing "CVI SQL Samples" with "Custom DB":

 

new code.JPG

In your code specifically, you can replace the DB name in line 26 where you use CopyString().

 

Hope this helps,

Bdog

Message 4 of 8
(3,544 Views)
Solution
Accepted by Hong_Kong

Hi Bdog,

 

Got it!  Thank you so much.

 

A note for other users:

 

In Windows 7, the Administrative Tools shows only the 64-bit ODBC.  The 32-bit ODBC is located here:

  • The 32-bit version of the Odbcad32.exe file is located in the %systemdrive%\Windows\SysWoW64 folder.
  • The 64-bit version of the Odbcad32.exe file is located in the %systemdrive%\Windows\System32 folder.

 

Message 5 of 8
(3,528 Views)

javierverduzco_0-1693000195281.png  

javierverduzco_0-1693000395003.png

 

Somebody reach the connection between SQL "No Access" and CVI, Currently i try to do the connection using SQL & CVI by ODBC?

0 Kudos
Message 6 of 8
(1,188 Views)

 

 

Hello I try to connecto to SQL Using a ODBC driver on Labwindows cvi , but i get the following error, I declared the connection but it doesn't work. I was worked on the example that cvi provides. if i perform a data source test it works properly.

 

 

javierverduzco_0-1693000651515.png   javierverduzco_1-1693000695601.png

 

javierverduzco_0-1693001028337.png

 

 

 

 

0 Kudos
Message 7 of 8
(1,209 Views)

The error message seems pretty clear. The database requires a login but there is no login configured. Either configure it in the ODBC DSN (no recommended) or provide the correct username and password to the DB Connect() function call.

Rolf Kalbermatter
My Blog
0 Kudos
Message 8 of 8
(1,149 Views)