Laszlo Sera
April 22nd, 1999, 05:01 PM
I used the code below in VC++ 5 and works fine, but when I use in VC++ 6 I got an error message ("Syntax error or access violation") after SQLBindParameter functions. Does anybody help me ?
The code is :
CString SQLStr("");
SDWORD cbName, cbFlag;
UCHAR szName[512];
SWORD sFlags;
SQLStr = "DELETE FROM BoxesURL WHERE BoxesURL.Box_ID=72";
SQLretcode = SQLPrepare(SQLhstmt, (UCHAR FAR *)"INSERT INTO BoxesLastSQLS (SQLStr,Flags) VALUES (?,?)", SQL_NTS);
if (SQLretcode == SQL_SUCCESS) {
SQLretcode = SQLBindParameter(SQLhstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR,
SQL_CHAR, 512, 0, szName, 0, &cbName);
SQLretcode = SQLBindParameter(SQLhstmt, 2, SQL_PARAM_INPUT, SQL_C_SSHORT,
SQL_SMALLINT, 0, 0, &sFlags, 0, &cbFlag);
strcpy((char *)szName, SQLStr);
sFlags = 4;
SQLretcode = SQLExecute(SQLhstmt);
if (SQLretcode == SQL_ERROR) {
theApp.SQLErrorDetect(SQLStr, SQLhenv, SQLhdbc, SQLhstmt);
SQLFreeStmt(SQLhstmt, SQL_UNBIND);
SQLFreeStmt(SQLhstmt, SQL_CLOSE);
return;
}
}
SQLFreeStmt(SQLhstmt, SQL_UNBIND);
SQLFreeStmt(SQLhstmt, SQL_CLOSE);
Laszlo Sera
The code is :
CString SQLStr("");
SDWORD cbName, cbFlag;
UCHAR szName[512];
SWORD sFlags;
SQLStr = "DELETE FROM BoxesURL WHERE BoxesURL.Box_ID=72";
SQLretcode = SQLPrepare(SQLhstmt, (UCHAR FAR *)"INSERT INTO BoxesLastSQLS (SQLStr,Flags) VALUES (?,?)", SQL_NTS);
if (SQLretcode == SQL_SUCCESS) {
SQLretcode = SQLBindParameter(SQLhstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR,
SQL_CHAR, 512, 0, szName, 0, &cbName);
SQLretcode = SQLBindParameter(SQLhstmt, 2, SQL_PARAM_INPUT, SQL_C_SSHORT,
SQL_SMALLINT, 0, 0, &sFlags, 0, &cbFlag);
strcpy((char *)szName, SQLStr);
sFlags = 4;
SQLretcode = SQLExecute(SQLhstmt);
if (SQLretcode == SQL_ERROR) {
theApp.SQLErrorDetect(SQLStr, SQLhenv, SQLhdbc, SQLhstmt);
SQLFreeStmt(SQLhstmt, SQL_UNBIND);
SQLFreeStmt(SQLhstmt, SQL_CLOSE);
return;
}
}
SQLFreeStmt(SQLhstmt, SQL_UNBIND);
SQLFreeStmt(SQLhstmt, SQL_CLOSE);
Laszlo Sera