L
mhh...okay...danke..
bei der msdn such ich die ganze zeit schon^^
und auch hier im forum..
aber hab vorher nie mit ner DB gearbeitet.
aber irgendwie scheint der sich doch nicht verbunden zu haben....und wirklich keine ahnung wieso...kommt auf jedenfalls nen SQL_ERROR nach SQLDRIVERCONNECT raus
zugriffsrechte auf den server hab ich...mein kollege weiß auch nicht woran das liegen kann
hab auch alle möglichen connectionsstrings ausprobiert...also in verschiedenen formen und so...
aber das funkzt einfach nich...
hier mal der sourcecode...
int cl_event::sql_open()
{
SQLHENV henv;
SQLHDBC hdbc;
SQLHSTMT hstmt;
SQLRETURN retcode;
SQLPOINTER rgbValue;
int i = 5;
rgbValue = &i;
SQLCHAR InConnStr[255]="Driver={SQL Server};Server=BASE-1;Database=TESTDB;Trusted_Connection=yes;Network=dbnmpntw;";
SQLWCHAR OutConnStr[255];
SQLSMALLINT OutConnStrLen;
// Allocate environment handle
retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
// Set the ODBC version environment attribute
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER*)SQL_OV_ODBC3, 0);
// Allocate connection handle
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
// Set login timeout to 5 seconds
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
SQLSetConnectAttr(hdbc, SQL_LOGIN_TIMEOUT, (SQLPOINTER)(rgbValue), 0);
retcode = SQLDriverConnect( // SQL_NULL_HDBC
hdbc,
NULL,
(SQLWCHAR*)InConnStr,
_countof(InConnStr),
OutConnStr,
255,
&OutConnStrLen,
SQL_DRIVER_NOPROMPT );
// Allocate statement handle
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
// Process data
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
}
SQLDisconnect(hdbc);
}
SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
}
}
SQLFreeHandle(SQL_HANDLE_ENV, henv);
}
return 0;
}