Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Copying data from a VARIANT (or ADO database read access)


1 reply to this topic

ebell

ebell
  • Full Members
  • 2 posts

Posted 14 May 2014 - 15:13

Hi!

 

I'm trying to read a value from an Access database during an InstallScript only based InstallShield installer.

 

I've already retrieved the value, but with the code I have, the value (which is of type VARIANT) is only available while the ADO recordset is open. I'm writing a helper routine to retrieve these values, and would prefer to close the recordset before returning the value for use by a function caller.

 

szADORecordSetObjID = "ADODB.Recordset";
set pADORecordSetObj = CreateObject(szADORecordSetObjID);

// Set some ADO Recordset properties 
pADORecordSetObj.CursorType = 3;
pADORecordSetObj.ActiveConnection = pADOConnObj;

// Use the recordset to run Query and retrieve single result
pADORecordSetObj.Open(szSQL);

varResult = pADORecordSetObj(0);

// varResult is available here. From my understanding it is basically just a pointer.

pADORecordSetObj.Close(); // and now the result is gone :<

return varResult; // therefore this won't work

I'm working from a codebase that already does this, but it did not close the recordset before returning. This gets the value returned, but leaves an open recordset! :o

 

Any suggestions? I'm looking now for a way to copy the value from the VARIANT, but another method for getting the database value would be fine, too.

 

Thanks in advance for any help!

 

- Everett



ebell

ebell
  • Full Members
  • 2 posts

Posted 14 May 2014 - 15:38

Bah, I wish I would have thought of this earlier. I used Sprintf to create a string from the VARIANT value. Doesn't handle all db types but this worked in my case.