Simple VC ADO request 
Author Message
 Simple VC ADO request

Could someone send me the code needed to open a recordset with ADO whee I am
passing the active connection at one of the parameters?

Given that I have a connection called MyConnection, created like this:

MyConnection.CreateInstance(__uuidof(Connection));
MyConnection->ConnectionString = (BSTR)L"DSN=TESTDB;UID=;PWD=";
MyConnection->Open(L"",L"",L"",-1);

Which is valid, as I have created several recordsets (using the execute
method), and viewed their contents.

I want to make a recordset using the recordsets Open method.

MySet.CreateInstance(__uuidof(Recordset));
MySet->->Open(L"SELECT * FROM Table1",
    ActiveConnection,
    adOpenDynamic,
    adLockOptimistic,
    adCmdText);

What is ActiveConnection?  I have tried:

MyConnection
(_variant_t&) MyConnection,
(_variant_t&) *MyConnection,
(_variant_t&) &MyConnection

and just about anything else I can think of.  Can someone either tell me
what activeConnection is looking for, or give me a simple Recordset->Open in
C++?

Thanks

Bob



Fri, 02 Feb 2001 03:00:00 GMT  
 Simple VC ADO request
Here's the way I do this....

  _variant_t   vtEmpty (DISP_E_PARAMNOTFOUND, VT_ERROR);
  _bstr_t       bstrEmpty(L"");

  MyConnection.CreateInstance(__uuidof ( Connection ) );
  MyConnection->ConnectionString = ....
  MyConnection->Open(bstrEmpty, bstrEmpty, bstrEmpty, -1);

  MySet.CreateInstance( __uuidof( Recordset ) );
  MySet->PutRefActiveConnection( MyConnection );
  MySet->Open(L"SELECT * FROM TABLE1", vtEmpty, adOpenDynamic, adCmdText);

Hope this helps....

Eric Raskin

Quote:

>Could someone send me the code needed to open a recordset with ADO whee I
am
>passing the active connection at one of the parameters?

>Given that I have a connection called MyConnection, created like this:

>MyConnection.CreateInstance(__uuidof(Connection));
>MyConnection->ConnectionString = (BSTR)L"DSN=TESTDB;UID=;PWD=";
>MyConnection->Open(L"",L"",L"",-1);

>Which is valid, as I have created several recordsets (using the execute
>method), and viewed their contents.

>I want to make a recordset using the recordsets Open method.

>MySet.CreateInstance(__uuidof(Recordset));
>MySet->->Open(L"SELECT * FROM Table1",
>    ActiveConnection,
>    adOpenDynamic,
>    adLockOptimistic,
>    adCmdText);

>What is ActiveConnection?  I have tried:

>MyConnection
>(_variant_t&) MyConnection,
>(_variant_t&) *MyConnection,
>(_variant_t&) &MyConnection

>and just about anything else I can think of.  Can someone either tell me
>what activeConnection is looking for, or give me a simple Recordset->Open
in
>C++?

>Thanks

>Bob



Fri, 02 Feb 2001 03:00:00 GMT  
 Simple VC ADO request
Sorry -- I forgot one parameter in the Open call!!!

  MySet->Open(L"SELECT...", vtEmpty, AdOpenDynamic, adLockReadOnly,
adCmdText);

I forgot the locking mode.  Oops!

Eric Raskin

Quote:

>Here's the way I do this....

>  _variant_t   vtEmpty (DISP_E_PARAMNOTFOUND, VT_ERROR);
>  _bstr_t       bstrEmpty(L"");

>  MyConnection.CreateInstance(__uuidof ( Connection ) );
>  MyConnection->ConnectionString = ....
>  MyConnection->Open(bstrEmpty, bstrEmpty, bstrEmpty, -1);

>  MySet.CreateInstance( __uuidof( Recordset ) );
>  MySet->PutRefActiveConnection( MyConnection );
>  MySet->Open(L"SELECT * FROM TABLE1", vtEmpty, adOpenDynamic, adCmdText);



Fri, 02 Feb 2001 03:00:00 GMT  
 Simple VC ADO request
Exactly what I was looking for.  thanks.  If I might ask, I have been
through just about every bit of documentation I can find, and I found no
reference to this.  where did you find/learn this?

Thanks a lot!

Bob



Fri, 02 Feb 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Simple VC ADO request

2. why my simple ado vc code get runtime error

3. Speed of ADO Recordset vs ADO Command in VC

4. Request for ADO Documentation

5. REQUEST: ADO example for CONSOLE (nonWIN) App!

6. Simple vsprintf source code request

7. Simple help request/

8. Request for simple date routines.

9. REQUEST: simple ANSI C text editor source

10. simple ole.com sample requested / no methods exposed

11. Comment Request on ATL and vc++

12. A request from a learner VC programmer.

 

 
Powered by phpBB® Forum Software