LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to retrieve rows from ado recordset

Hi,
I am using ADO for retirieve data from MSSQL server.
I can create recordset with sql query and execute it successfuly.
So now i have CAObjHandle of the recordset and I need to retrieve data.
Do you have any examples/suggestions for this case?
 
 
Thanks a lot
0 Kudos
Message 1 of 5
(4,183 Views)

Hello,

 

Thank you for posting to the NI Discussion Forums.  Are you using the CVI SQL toolkit?  It sounds like you are directly communicating to the database using ActiveX.  If this is the case, the ActiveX connection handle is the CAObjectHandle which you will use to pass around to the other functions.  It is up to the database provider to publish and document the exact ActiveX functions made available.  Unfortunately, I don’t know the exact call to make, but if you are unfamiliar with ActiveX in CVI check out this tutorial which will hopefully get you started.

 If you are intersted in the SQL toolkit which will make this much easier check out this link.

Hope it helps!

Message Edited by Travis M. on 07-17-2006 01:34 PM

Travis M
LabVIEW R&D
National Instruments
0 Kudos
Message 2 of 5
(4,163 Views)
Hi, thank you for replay.
I read about using activeX in Labwindows/CVI and about SQL Toolkit.
It's clear to me that Microsoft (database provider) doesn't want to publish  examples how to use ADO with CVI.
I can find a lot of examples how to use ADO with VC, VC++,VB, C# for free.
When I payed money to NI and you have promised me technical support.
DB access is basic task for environment like CVI, and now You offer me to buy something else(like SQL Toolkit)
in order to get your support.
I have simple problem:
CAObjHandle connectionHandle = S_OK;
CAObjHandle rsHandle = S_OK;
LPDISPATCH lpDispatch;
VARIANT dbConnection;
VARIANT source;
ERRORINFO err ;

ADODB_New_Connection (NULL, 1, LOCALE_NEUTRAL, 0, &connectionHandle);
ADODB__ConnectionOpen (connectionHandle, NULL, "DSN=test;UID="";PWD="";", "", "", -1);
CA_GetInterfaceFromObjHandle (connectionHandle, 0, 0, &lpDispatch, NULL);
dbConnection = CA_VariantDispatch (lpDispatch);
ADODB_New_Recordset (NULL, 1, LOCALE_NEUTRAL, 0, &rsHandle);
CA_VariantSetCString (&source, "SELECT * FROM TABLE");
ADODB__RecordsetOpen (rsHandle, &err, source, dbConnection, ADODBConst_adOpenStatic,ADODBConst_adLockReadOnly, -1);

 I just can't find how ti retrieve data from recordset. Pls, help me if you can.
 Incidentally, If you know another way to connect to db and retrieve data from, pls suggest
 
Thank you
 
0 Kudos
Message 3 of 5
(4,134 Views)

Good afternoon,

 

Thanks for the reply with the clarification.  It sounds like you are indeed using the low-level ActiveX interface to communicate with your database.  The toolkit just provides a clean and easy to use wrapper for the ActiveX calls and doesn’t really add any sort of functionality that you couldn’t implement with these ActiveX calls.  It’s certainly not necessary to communicate with databases in CVI.  However, the scope of our support is usually limited to our products.  Since the provider of your database implements the ActiveX code you are using, support for that interface will come from that particular provider.  If you have any questions at all on how to use the ActiveX library functions in CVI to interface with general ActiveX calls please let us know.  Most of the material we have related to this is covered in the tutorials provided, but if any of it is unclear we’ll be happy to help. 

 

Thanks again for posting, and I hope that the ActiveX libraries and examples (Help->Find Examples) will provide you with a great wealth of knowledge for the ActiveX capabilities of CVI.

 

Wishing you well-

Travis M
LabVIEW R&D
National Instruments
0 Kudos
Message 4 of 5
(4,107 Views)
pdobkes,
 
You don't have to use ActiveX in order to access a database through C.  In fact, Microsoft provides, (with the MDAC 2.7+ component library which you can download from msdn for free) a perfectly usable, and in fact very robust API for database interaction.  This is called ODBC, and you can follow this link http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcabout_this_manual.asp, to learn more about it.
 
ADO is geared much more towards an OO language (hence the need for an ActiveX control) , ODBC is more what you are looking for if you want to use database interaction in C.
0 Kudos
Message 5 of 5
(4,082 Views)