I am using the following code and I can't connect to the database. The app and the server are on the same PC. I am able to manage the server through SQL Server Management Studio.
#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include <sqltypes.h>
#include <stdio.h>
#include <sql.h>
#include <sqlext.h>
int _tmain(int argc, _TCHAR* argv[])
{
SQLHENV henv;
SQLHDBC hdbc;
SQLHSTMT hstmt;
SQLRETURN retcode;
SQLWCHAR SqlState[6], SQLStmt[100], Msg[SQL_MAX_MESSAGE_LENGTH];
SQLINTEGER NativeError;
SQLSMALLINT MsgLen;
SQLCHAR * OutConnStr = (SQLCHAR * )malloc(255);
SQLSMALLINT * OutConnStrLen = (SQLSMALLINT *)malloc(255);
// Allocate environment handle
retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
// check is environment handle set
if(retcode != SQL_SUCCESS)
{
std::cout << "Failed to allocate environm ...
Go to the complete details ...