Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input/Output String Parameter for Stored Procs

Status
Not open for further replies.

RWThurman

Programmer
Mar 30, 2007
1
US
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::print("system", "Error in SQL statement loginPlayer.\n");
Channel::print("system", std::string((char*)errorMessage) + std::string("\n"));
return;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top