freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
[freetds] Does SQLBindParameter work with SQLExecDirect
- From: "David Fraser" <david AT abelon.com>
- To: "FreeTDS" <freetds AT lists.ibiblio.org>
- Subject: [freetds] Does SQLBindParameter work with SQLExecDirect
- Date: Wed, 6 Aug 2003 11:16:19 +0100
Hi,
I'm using FreeTDS 0.61 and TDS-ver is 7.0.
I can get SQLBindParameter to work with SQLPrepare/SQLExecute,
but it fails when I try SQLExecDirect.
I get sqlState of HY000, nativeError=1, and the message
is "Line 1: Incorrect syntax near '?'".
Is this a known bug, or am I doing something daft? The MS API
Reference implies this is a legal sequence of ODBC API calls.
Alternatively - as this just not been implemented (yet)?
(i.e. "just use SQLPrepare stoopid!" :-)
For reference (and ridicule :-) here's a test snippet that fails...
SQLCHAR queryString[200];
strcpy( (char *)queryString,
"SELECT * FROM MyTable WHERE MyField = ?" );
SQLINTEGER lenOrInd = 0;
SQLINTEGER myVal = 1;
status = SQLBindParameter(statementHandle, 1, SQL_PARAM_INPUT,
SQL_C_SSHORT,
SQL_INTEGER, 0, 0, &myVal, 0, &lenOrInd );
if (status != SQL_SUCCESS ) {
printf( "SQLBindParameter failed" );
return;
}
status = SQLExecDirect( statementHandle, queryString, SQL_NTS );
if (status != SQL_SUCCESS ) {
printf( "Execute failed" );
return;
}
And here's the snippet that succeeds...
SQLCHAR queryString[200];
strcpy( (char *)queryString,
"SELECT * FROM MyTable WHERE MyField = ?" );
status = SQLPrepare( statementHandle, queryString, SQL_NTS );
if (status != SQL_SUCCESS ) {
printf( "Prepare failed" );
return;
}
SQLINTEGER lenOrInd = 0;
SQLINTEGER myVal = 1;
status = SQLBindParameter(statementHandle, 1, SQL_PARAM_INPUT,
SQL_C_SSHORT,
SQL_INTEGER, 0, 0, &myVal, 0, &lenOrInd );
if (status != SQL_SUCCESS ) {
printf( "SQLBindParameter failed" );
return;
}
status = SQLExecute( statementHandle );
if (status != SQL_SUCCESS ) {
printf( "Execute failed" );
return;
}
Thanks in advance,
David
-
[freetds] Does SQLBindParameter work with SQLExecDirect,
David Fraser, 08/06/2003
- <Possible follow-up(s)>
-
RE: [freetds] Does SQLBindParameter work with SQLExecDirect,
ZIGLIO Frediano, 08/06/2003
-
Re: [freetds] Does SQLBindParameter work with SQLExecDirect,
David Fraser, 08/07/2003
-
Re: [freetds] Does SQLBindParameter work with SQLExecDirect,
Frediano Ziglio, 08/07/2003
- Re: [freetds] Does SQLBindParameter work with SQLExecDirect, David Fraser, 08/08/2003
-
Re: [freetds] Does SQLBindParameter work with SQLExecDirect,
Frediano Ziglio, 08/07/2003
-
Re: [freetds] Does SQLBindParameter work with SQLExecDirect,
David Fraser, 08/07/2003
- RE: [freetds] Does SQLBindParameter work with SQLExecDirect, ZIGLIO Frediano, 08/08/2003
-
RE: [freetds] Does SQLBindParameter work with SQLExecDirect,
Lowden, James K, 08/08/2003
- Re: [freetds] Does SQLBindParameter work with SQLExecDirect, David Fraser, 08/08/2003
Archive powered by MHonArc 2.6.24.