ODBC & Stored Procedures 
Author Message
 ODBC & Stored Procedures

How can I call a stored procedure with ODBC API. If this is not
possible what is the recommended way of doing this?

Thanks
Chirath



Sat, 09 Oct 2004 18:51:44 GMT  
 ODBC & Stored Procedures
Please refer to ODBC API SDK on MSDN. There is many example on how to
execute stored procedure using ODBC API. For example:

// Declare a binary buffer to retrieve 5000 bytes of data at a time.
SQLCHAR       BinaryPtr[5000];
SQLUINTEGER   PartID;
SQLINTEGER    PartIDInd, BinaryLenOrInd, NumBytes;
SQLRETURN     rc;
SQLHSTMT      hstmt;

// Create a result set containing the ID and picture of each part.
SQLExecDirect(hstmt, "SELECT PartID, Picture FROM Pictures", SQL_NTS);

// Bind PartID to the PartID column.
SQLBindCol(hstmt, 1, SQL_C_ULONG, &PartID, 0, &PartIDInd);

// Retrieve and display each row of data.
while ((rc = SQLFetch(hstmt)) != SQL_NO_DATA) {
   // Display the part ID and initialize the picture.
   DisplayID(PartID, PartIDInd);
   InitPicture();

   // Retrieve the picture data in parts. Send each part and the number
   // of bytes in each part to a function that displays it. The number
   // of bytes is always 5000 if there were more than 5000 bytes
   // available to return (cbBinaryBuffer > 5000). Code to check if
   // rc equals SQL_ERROR or SQL_SUCCESS_WITH_INFO not shown.
   while ((rc = SQLGetData(hstmt, 2, SQL_C_BINARY, BinaryPtr,
sizeof(BinaryPtr),
                           &BinaryLenOrInd)) != SQL_NO_DATA) {
      NumBytes = (BinaryLenOrInd > 5000) || (BinaryLenOrInd ==
SQL_NO_TOTAL) ?
                  5000 : BinaryLenOrInd;
      DisplayNextPictPart(BinaryPtr, NumBytes);
   }

Quote:
}

// Close the cursor.
SQLCloseCursor(hstmt);

Thanks,
Kevin

This posting is provided ?AS IS? with no warranties, and confers no
rights.

--------------------

| Newsgroups: microsoft.public.vc.language
| Subject: ODBC & Stored Procedures
| Date: 23 Apr 2002 03:51:44 -0700
| Organization: http://groups.google.com/
| Lines: 5

| NNTP-Posting-Host: 202.124.160.66
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google.com 1019559104 18611 127.0.0.1 (23 Apr 2002
10:51:44 GMT)

| NNTP-Posting-Date: 23 Apr 2002 10:51:44 GMT
| Path:
cpmsftngxa08!cpmsftngxa06!cpmsftngxa07!tkmsftngp01!newsfeed00.sul.t-online.d
e!t-online.de!fr.usenet-edu.net!usenet-edu.net!fr.clara.net!heighliner.fr.cl
ara.net!proxad.net!isdnet!sn-xit-02!supernews.com!postnews1.google.com!not-f
or-mail
| Xref: cpmsftngxa08 microsoft.public.vc.language:160131
| X-Tomcat-NG: microsoft.public.vc.language
|
| How can I call a stored procedure with ODBC API. If this is not
| possible what is the recommended way of doing this?
|
| Thanks
| Chirath
|



Sun, 10 Oct 2004 21:20:34 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. ODBC, Stored Procedures & Temporary Tables

2. odbc and stored procedures

3. Stored Procedure's Fetch Fails Via ODBC

4. Calling a store procedure with ODBC

5. ODBC: Passing embedded quotes to stored procedures

6. ODBC + Oracle + MFC + Stored Procedure

7. ODBC Stored Procedure and varchar argument

8. MFC ODBC classes and Stored Procedures

9. HowTo: ODBC and Stored Procedures

10. Empty output parameters when executing stored procedure through ODBC

11. store procedure (ODBC)

12. Stored Procedure's Fetch Fails Via ODBC

 

 
Powered by phpBB® Forum Software