INSERT INTO with SQLPrepare() and SQLExecute() 
Author Message
 INSERT INTO with SQLPrepare() and SQLExecute()

I have a really strange problem.  I am developing an ODBC library for
internal use and have recently started working on the INSERT functionality.
I tried it first in a simple form as:

SQLRETURN retval = SQLExecDirect(hstmt,string,SQL_NTS);
where string contained:
INSERT INTO Categories (ID, Name, Description) VALUES (1,'Testing','A test

This would return SQL_SUCCESS, but no insert occurred in the database.  So,
I fleshed in the current version:

SQLRETURN retval = SQLPrepare(hstmt,statement,strlen(statement));
if (retval == SQL_SUCCESS || retval == SQL_SUCCESS_WITH_INFO)
   retval = SQLExecute(hstmt);
   if (retval == SQL_SUCCESS || retval == SQL_SUCCESS_WITH_INFO)

with the statement: INSERT INTO Categories (ID, Name, Description) VALUES

The values are SQLBindParameter() bound.  Guess what?  It returns
SQL_SUCCESS and nothing is written to the file.  An ODBC trace shows:

testing         584-4c4 EXIT  SQLPrepare  with return code 0 (SQL_SUCCESS)
  HSTMT               007E2FF8
  UCHAR *             0x0096AAA8 [      62] "INSERT INTO Categories (ID,
Name, Description) VALUES (?,?,?);"
  SDWORD                    62
testing         584-4c4 EXIT  SQLExecute  with return code 0 (SQL_SUCCESS)
  HSTMT               007E2FF8
testing         584-4c4 EXIT  SQLEndTran  with return code 0 (SQL_SUCCESS)
  SQLSMALLINT                  2 <SQL_HANDLE_DBC>
  SQLHANDLE           007E1958
  SQLSMALLINT                  0

I am at my wits end?  Anyone have any suggestions for me as to why this does
not work?  Thanks in advance for any help....

Sat, 15 Mar 2003 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Validate SQL parameters at SQLExecute time

2. SQLExecute with Parameter Array

3. SQLExecute() causes an access violation

4. Stored Procedure Execution using SQLExecute

5. Need help with SQLExecute

6. SQLExecute/SQLFetch from .dll based virutal function

7. Trouble with SQLExecute from within a Callback

8. Help insert statement taking longer on each insert, a d:\temp\CT??.tmp getting progressively bigger on each insert

9. Help needed: SQLExecute fails with S1090 (Invalid string or buffer length).

10. Problems inserting DataSet into OleDbDataAdapter

11. Detecting Insert Key State

12. Correction: Inserting ActiveX in a Non-Form project


Powered by phpBB® Forum Software