LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to query AS400 for data via sql/odbc/activex from LabWindows program??

Hello.  I am very new to C and very, very, very new to LabWindows.

 

I am inheriting a software program written using LabWindows/CVI 8.5 from Japan and trying to interface it into our AS/400 database.  The program they wrote needs to know whether it is checking left-hand or right-hand parts.  This is GOING to be accomplished by scanning a barcode label, then programatically connecting to our AS/400 and looking up that barcode.  I have dozens of ASP, VB6, VB.net, C#.net, etc programs connecting to our AS/400 with no problems whatsoever...I even played around in Microsoft Visual C++6 and got that to work fine too...

 

...but everything I try in LabWindows/CVI just fails absolutely.  It's very discouraging.  😞  Plus, I have a short time to make this work before my company may abandon this project entirely...so...not a great position to be in.

 

Any ideas?  I have tried creating a dll that I could call, since I had so many problems doing the odbc connection directly in LW/CVI, but that failed.  Also, I tried what worked in VC++6, using "#import[...]\msado15.dll" but LW/CVI did not like the #import command at all. 

 

Any ideas??  Please?  Thanks!

 

If I can get this to work, I also need to then turn around and log the data test points back to our AS/400 system as well...so this is integral to the project.  Guidance?  Sympathy?  🙂

0 Kudos
Message 1 of 9
(5,368 Views)

Hi,

 

you can interface the database via odbc and therefore ADO/OleDB. Perhaps NI CVI/SQL (http://joule.ni.com/nidu/cds/view/p/id/1006/lang/de) will help you? Otherwise, I can suggest our company's porduct, called XOnADO.

 

Peter

0 Kudos
Message 2 of 9
(5,363 Views)

Thanks for the quick response.  I have tried to access it via odbc, using the header files and odbc32.lib from the Windows SDK as well as just now with the SDK files in the C:\Program Files\National Instruments\CVI85\sdk\include location, but I keep getting these strange errors:

 

 AS400.c - 20 errors, 2 warnings
  "SqlTypes.h"(135,33)   syntax error; found 'identifier' expecting ';'.
  "SqlTypes.h"(274,5)   syntax error; found 'identifier' expecting '}'.
  "SqlTypes.h"(274,15)   Warning: Empty declaration.
  "SqlTypes.h"(275,10)   syntax error; found 'identifier' expecting ';'.
  "SqlTypes.h"(276,10)   syntax error; found 'identifier' expecting ';'.
  "SqlTypes.h"(277,1)   Unrecognized declaration.
  "SqlExt.h"(1681,5)   Missing parameter type.
  "SqlExt.h"(1681,24)   syntax error; found 'identifier' expecting ')'.
  "SqlExt.h"(2012,54)   Extraneous formal parameter specification.
  "SqlExt.h"(2014,9)   syntax error; found '__stdcall' expecting ';'.
  "SqlExt.h"(2043,17)   syntax error; found '*' expecting ';'.
  "SqlExt.h"(2046,9)   Invalid union field declarations.
  "SqlExt.h"(2046,9)   syntax error; found 'identifier' expecting '}'.
  "SqlExt.h"(2047,9)   syntax error; found 'identifier' expecting '}'.
  "SqlExt.h"(2047,23)   Warning: Empty declaration.
  "SqlExt.h"(2048,5)   Unrecognized declaration.
  "SqlExt.h"(2050,9)   Invalid union field declarations.
  "SqlExt.h"(2050,9)   syntax error; found 'identifier' expecting '}'.
  "SqlExt.h"(2051,17)   syntax error; found '*' expecting ';'.
  "SqlExt.h"(2051,17)   Unrecognized declaration.
  "SqlExt.h"(2052,5)   Unrecognized declaration.
  "SqlExt.h"(2054,1)   Unrecognized declaration.

 I am at a total loss.  😞  ADO/OleDB is exactly what Iwould like to use, as it is consistent with our other programs.  I don't think management will spring for the CVI/SQL package or anything else extra.  What am I doing wrong?  I have added sql.h, sqlext.h, sqltypes.h,sqlucode.h, and odbc32.lib.  This worked fine in VC6.  Now these headers that were provided by NI are somehow not being liked by NI.

 

Thanks in advance!

0 Kudos
Message 3 of 9
(5,358 Views)

Sorry, I'm not familiar with these headers. Looks like some problems with the include files, perhaps cvi's "utility.h" causes problems when including windows.h ? Try to change the order of include file sin your project, perhaps it might help. Otherwise, I use our tool ...

 

regards

 

Peter

Message 4 of 9
(5,355 Views)

I'm not familiar with these header, either.

But it looks as you are missing another include or  command-line define.

Have you included windows.h and sql.h?

 

In my opinion, this kind of problem is easier to solve when you work on a preprocessed filed. ( You can do that with Options/ Preprocess source file)

 

Best regards.

Nicolas

Message 5 of 9
(5,341 Views)

maybe a dumb question but...

 

have you tried CVI SQL ? it is installed separately from LabWindows/CVI, and will let you connect easily to ODBC or ADO providers, plus it ships with LabWindows, and will of course work with it... 

 

if you understand the concept of database and SQL, the API for CVI SQL are easy to use.

0 Kudos
Message 6 of 9
(5,328 Views)

The strange errors did go away after I added windows.h and made sure the sql headers were all in the particular file I was dealing with!  Thanks everyone!

 

Regarding the CVI SQL package, that is an additional expense, correct?  If so, then it probably won't happen.  😞

 

But, now that my sql errors are gone I just have to figure out how to make my working VC6 code into ANSI C for LabWindows...

0 Kudos
Message 7 of 9
(5,326 Views)

LukeG@HA wrote:

"Regarding the CVI SQL package, that is an additional expense, correct?"

 

well... i don't know. here at work, i only have to pick the NI CD case off the shelf and install the component i need. i don't know what is included with a standard CVI distribution. can anyone at NI confirm this ?

0 Kudos
Message 8 of 9
(5,318 Views)

The LabWindows/CVI SQL toolkit is included in a Developer Suite purchase.  Otherwise, it is a separate purchase from LabWindows/CVI.  However, there is a 30 day free trial for users who wish to evaluate the product.  More information can be found at the following page:

 

LabWindows/CVI SQL Toolkit 2.1

 

Matt G.

 

National Instruments

Applications Engineering

0 Kudos
Message 9 of 9
(5,305 Views)