The function prototype is as follows:
SQLRETURN SQLBindParameter(
SQLHSTMT StatementHandle,
SQLUSMALLINT ParameterNumber,
SQLSMALLINT InputOutputType,
SQLSMALLINT ValueType,
SQLSMALLINT ParameterType,
SQLULEN ColumnSize,
SQLSMALLINT DecimalDigits,
SQLPOINTER ParameterValuePtr,
SQLLEN BufferLength,
SQLLEN * StrLen_or_IndPtr);
I am more interested in parameters 6,8 9 and 10 and how they apply to variable strings. Other built-in data types seem less problematic All the examples I have seen on the internet e.g. http://msdn.microsoft.com/en-us/library/ms709287(v=vs.85).aspx use static arrays which seems straight forward. But I want to use a std::vector and all my attempts have failed.
So say I want to bind these strings.
std::vector<std::string> countries = boost::assign::list_of("Argentina")( "Burkina Faso")( "China")( "Dominica Republic");
Note: I am using std::vector<string>
for conveniece of declaration.
I cannot send c.str()
to the database the driver should be able to modify the string in some situations
So I declare a buffer like this
std::vector<char> my_data;
and copy my strings to the buffer.
How then should I pass these parameters:
ColumnSize ?
ParameterValuePtr ? // this I think I am sure should be &my_data[0]
BufferLength ?