Im working on a program that are accessing a SQL server.
I've established the connection, and i can get the stand i want, but only when my SQL Query is static.
I've read a post in here, where the same question was asked, tried his solution, which sadly didn't work (8 years old post also).
The function used to gain the Query is the following:
SQLWCHAR ConstructQuery()
{
wstring temp = L"SELECT Something FROM somewhere WHERE condition";
SQLWCHAR statement = (SQLWCHAR)temp.c_str();
return statement;
}
and my code for running this query is as follows:
SQLStatement = ConstructQuery();
SQLExecDirect(sqlStmtHandle,&SQLStatement, SQL_NTS))
SQLCHAR sqldata[SQL_RESULT_LEN];
SQLINTEGER ptrsqldata;
while (SQLFetch(sqlStmtHandle) == SQL_SUCCESS) {
SQLGetData(sqlStmtHandle, 1, SQL_CHAR, sqldata, SQL_RESULT_LEN, &ptrsqldata);
//display query result
cout << "\nQuery Result:\n\n";
cout << sqldata << endl;
}
The code runs, but i dont get any output.
Does anyone has any advice ? :-)