I'm trying to bind an input/output string parameter for a stored procedure. I'm running against a Microsoft SQL database.
Here's the code I'm using to bind my parameter:
// accountName is a std::string& passed in.
char accountNameBuffer[128];
strncpy(accountNameBuffer, accountName.c_str(), 128);
SQLINTEGER accountNameSize = SQL_NTS;
result = SQLBindParameter(
statementHandle,
3,
SQL_PARAM_INPUT_OUTPUT,
SQL_C_CHAR,
SQL_VARCHAR,
SQLINTEGER(64),
0,
SQLPOINTER(accountNameBuffer),
128,
&accountNameSize);
assert(SQL_SUCCESS == result);
When I execute the stored procedure with the code down below, I get an error saying, "Microsoft][ODBC SQL Server Driver]Indicator variable required but not supplied". dbo.ls_GameServerLogin is a stored procedure that accepts 17 parameters, and I've checked all the other parameters several times. FYI, sqlState is set to 22002, nativeError is set to 0, and errorMessageNumber is set to 79.
Is there something wrong with my binding?
std::string sqlStatement("{ call dbo.ls_GameServerLogin(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) }");
result = SQLExecDirectA(
statementHandle,
(SQLCHAR *)(sqlStatement.c_str()),
SQLINTEGER(sqlStatement.size()));
if (result < SQL_SUCCESS)
{
SQLCHAR sqlState[32];
SQLINTEGER nativeError;
SQLCHAR errorMessage[1024];
SQLSMALLINT errorMessageNumber;
result = SQLErrorA(
m_environmentHandle,
m_connectionHandle,
statementHandle,
sqlState,
&nativeError,
errorMessage,
1024,
&errorMessageNumber);
Channel:rint("system", "Error in SQL statement loginPlayer.\n");
Channel:rint("system", std::string((char*)errorMessage) + std::string("\n"));
return;
}
Here's the code I'm using to bind my parameter:
// accountName is a std::string& passed in.
char accountNameBuffer[128];
strncpy(accountNameBuffer, accountName.c_str(), 128);
SQLINTEGER accountNameSize = SQL_NTS;
result = SQLBindParameter(
statementHandle,
3,
SQL_PARAM_INPUT_OUTPUT,
SQL_C_CHAR,
SQL_VARCHAR,
SQLINTEGER(64),
0,
SQLPOINTER(accountNameBuffer),
128,
&accountNameSize);
assert(SQL_SUCCESS == result);
When I execute the stored procedure with the code down below, I get an error saying, "Microsoft][ODBC SQL Server Driver]Indicator variable required but not supplied". dbo.ls_GameServerLogin is a stored procedure that accepts 17 parameters, and I've checked all the other parameters several times. FYI, sqlState is set to 22002, nativeError is set to 0, and errorMessageNumber is set to 79.
Is there something wrong with my binding?
std::string sqlStatement("{ call dbo.ls_GameServerLogin(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) }");
result = SQLExecDirectA(
statementHandle,
(SQLCHAR *)(sqlStatement.c_str()),
SQLINTEGER(sqlStatement.size()));
if (result < SQL_SUCCESS)
{
SQLCHAR sqlState[32];
SQLINTEGER nativeError;
SQLCHAR errorMessage[1024];
SQLSMALLINT errorMessageNumber;
result = SQLErrorA(
m_environmentHandle,
m_connectionHandle,
statementHandle,
sqlState,
&nativeError,
errorMessage,
1024,
&errorMessageNumber);
Channel:rint("system", "Error in SQL statement loginPlayer.\n");
Channel:rint("system", std::string((char*)errorMessage) + std::string("\n"));
return;
}