Calling stored procedure with OLEDB? 
Author Message
 Calling stored procedure with OLEDB?

Does anyone know of a good example of how to call stored procedures from OLE
DB in C++?


Sat, 07 Feb 2004 22:59:00 GMT  
 Calling stored procedure with OLEDB?
Use ATL OLE DB Templates.
There are lot of samples in MSDN and Platform SDK.
Specifically,
Look at CCommand template. It's very simple.

Regards,
Dmitry Mashkov


Quote:
> Does anyone know of a good example of how to call stored procedures from
OLE
> DB in C++?



Sun, 08 Feb 2004 17:11:21 GMT  
 Calling stored procedure with OLEDB?
Hi, if you want to call stored procedure with OLEDB, you can have two
choice:

1, Use all the raw interfaces provided by OLE DB objects, this process is
rather complex. For detailed information, you can refer to the following
link.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/oled...
ledbole_db_structures_and_enumerated_types.asp

2. To simplify this process, ATL provide many helper class to do this job,
such as CDBPropSet, CDataSource, CSession....   You can use the following
code to call a store procedure in SQL Server.

CDBPropSet ps (DBPROPSET_DBINIT);
ps.AddProperty (DBPROP_AUTH_USERID, OLESTR ("sa"));
ps.AddProperty (DBPROP_AUTH_PASSWORD, OLESTR (""));
ps.AddProperty (DBPROP_INIT_DATASOURCE, OLESTR ("(local)"));
ps.AddProperty (DBPROP_INIT_CATALOG, OLESTR ("Customer"));
ps.AddProperty (DBPROP_INIT_PROMPT, (short)DBPROMPT_NOPROMPT);

CDataSource ds;
if (SUCCEEDED (ds.OpenWithServiceComponents (_T    
   ("SQLOLEDB"), &ps))) {
    CSession session;
    if (SUCCEEDED (session.Open (ds)) {
         TCHAR szCommand[] = _T ("sp_Customer 111303461,  5000");
         CCommand<CNoAccessor, CNoRowset> cmd;
         cmd.Open (session, szCommand);
       .......................
    }

Quote:
}

Note, in the above code, the stored procedure is called to run but no
records are return because we define no Accessor, if you want to get the
returned records, you will have to define a class that derive from
CAccessor.

Thanks,
Kelton



Mon, 09 Feb 2004 13:42:47 GMT  
 Calling stored procedure with OLEDB?
Been working on this stuff for a while.... this should work... stored proc
is Select * from Amplifier, very simple but you get the idea.

OleDbConnection MyConn = new OleDbConnection(strConn) ;
// Stored procedure is AmplifierDetails
DataSet MasterDataSet = new DataSet() ;
OleDbCommand myCommand = new OleDbCommand("AmplifierDetails", MyConn) ;
myCommand.CommandType = CommandType.StoredProcedure;

OleDbDataAdapter myAdapter = new OleDbDataAdapter();
myAdapter.SelectCommand = myCommand;
myAdapter.Fill(MasterDataSet, "AmplifierTable");
DataTable AmplifierTable = MasterDataSet.Tables["AmplifierTable"];

Then you can use AmplifierTable......


Quote:
> Does anyone know of a good example of how to call stored procedures from
OLE
> DB in C++?



Mon, 09 Feb 2004 23:55:04 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Calling stored procedure with OLEDB?

2. Problems calling Oracle stored procedures from VC++ over ADO(OLEDB)

3. how to using OLEDB access the SQL store Procedure

4. Problems passing parameters to ORACLE stored procedure with ATL/OLEDB

5. Help with VC++ / OLEDB / Stored procedures....

6. Execute stored procedure using OLEDB

7. OleDb and Oracle Stored Procedures

8. passing array to stored procedure with oledb

9. calling Stored procedure using OleDbConnection

10. Calling SQL stored procedure

11. Retrieving output parameters from a stored procedure call??

12. Call stored procedure

 

 
Powered by phpBB® Forum Software