I am programming on my macbook pro and need to connect to my company's MSSQL server for programming a commercial product.
How do you actually connect to it? I was looking on the MSDN website, and i didnt quite get it.
for the purposes of my demo, i was just going to create a new project within XCODE and just create a console application which will output the data. Once that it set up, ill implement different things with the connection.
Edit: Added some code:
#include <iostream>
//#include <windows.h>
#include <sqlext.h>
#include <sqltypes.h>
#include <sql.h>
using namespace std;
int main(int argc, const char * argv[])
{
SQLHENV hEnv;
SQLHDBC hDbc;
string connection = "AAA";
string db = "DB";
string user = "user";
string pass = "password";
string data = "DRIVER={SQL Server Native Client 11.0};SERVER="+connection+";DATABASE="+db+";UID="+user+";PWD="+pass+";";
//SQLCHAR* pwszConnStr = (SQLCHAR*)("Driver={SQL Server Native Client 11.0};Server="+connection+";Database="+db+";Uid="+user+";Pwd="+pass+";");
SQLCHAR* pwszConnStr = (SQLCHAR*)data.c_str();
//cout << data << endl;
cout << pwszConnStr << endl;
//error seems to occur in 1 of the 3 SQL statements below.
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &hEnv);
SQLSetEnvAttr(hEnv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, 0);
SQLAllocHandle(SQL_HANDLE_DBC, hEnv, &hDbc);
RETCODE rc = SQLDriverConnect(hDbc, NULL, pwszConnStr, SQL_NTS, NULL, 0, NULL, SQL_DRIVER_PROMPT);
if(rc == SQL_SUCCESS){
cout << "Connected to the Database" << endl;
}else{
cout << "No Connection Established" << endl;
}
return 0;
}
It fails to compile, and i am thinking it is related to me commenting out the windows.h file. The issue is that windows.h is not found on my macbook pro and figure it is when developing in VStudios.