LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

why does the ADO create query fail?

I have successfully create an activex controller from ADO. Below I am opeing a database and then trying to build a query. In this case I just want to count the number of records in the database. My DAO_DatabaseCreateQueryDef() command is failing. Can anyone tell me what is wrong with this code?

iRc = DAO_NewDBEngineDBEngine (NULL, 1, LOCALE_NEUTRAL, 0, &CAOHEngine);

iRc = DAO_DBEngineCreateWorkspace (CAOHEngine, NULL, "WORKSP1", "name", "password", CA_VariantInt (DAOConst_dbUseODBC), &DAOOWorkspace);

iRc = CA_CStringToBSTR ("SELECT * FROM main_balance", &bstrConn);
iRc = CA_CStringToBSTR ("", &bstrQuery);
iRc = DAO_WorkspaceOpenDatabase (DAOOWorkspace, NULL, "chicagowebs", CA_DEFAULT_VAL,CA_DEFAULT_VAL, CA_DEFAULT_VAL,
&DAOOdatabase);

iRc= DAO_DatabaseCreateQueryDef (DAOOWorkspace, NULL, CA_VariantBSTR (bstrQuery), CA_VariantBSTR (bstrConn), &DAOQuery);

iRc = DAO_DatabaseOpenRecordset (DAOOdatabase, NULL, "main_balance", CA_DEFAULT_VAL, CA_DEFAULT_VAL,
CA_DEFAULT_VAL, &DAORecordset);

iRc=DAO_GetRecordsetProperty (DAORecordset, NULL,
DAO_RecordsetRecordCount, CAVT_LONG, &iVal);
0 Kudos
Message 1 of 1
(2,593 Views)