none
C++ SQL RRS feed

  • Question

  • Hello im new to c++ but I need to pass a variable to retrieve data from my sql database. I have my connection working but im really lost on how I start my select query. Could some please help me understand what to do next ?

    Thanks

    const int MAX_CHAR = 1024; SQLCHAR SQLStmt[MAX_CHAR]; char strSQL[MAX_CHAR]; char chrTemp; // Get a handle to the database SQLHENV EnvironmentHandle; RETCODE retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &EnvironmentHandle); // Set the SQL environment flags retcode = SQLSetEnvAttr(EnvironmentHandle, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, SQL_IS_INTEGER); // create handle to the SQL database SQLHDBC ConnHandle; retcode = SQLAllocHandle(SQL_HANDLE_DBC, EnvironmentHandle, &ConnHandle); // Open the database using a System DSN retcode = SQLDriverConnect(ConnHandle, NULL, (SQLWCHAR*)"DSN=database;UID=****;PWD=*****;", SQL_NTS, NULL, SQL_NTS, NULL, SQL_DRIVER_NOPROMPT); if (!retcode) { cout << "SQLConnect() Failed"; } else { cout << "SQLConnect() passed";

    // select query }





    Wednesday, April 4, 2018 5:28 PM

All replies