Hi,ina windows service i'm trying to connect to a SQL Server 2014 Database. If the sql server is up and the database is running, the connection works fine.When the computer is rebootet my own service does not start often. In this case the service writest the a message into the eventlog noting, that the database was not found.First i tried to set my own service to depend on the sql server. Unfortunately this did not solve the problem. Now i'm trying to realize some retries using the SQL_ATTrCONNECTION_TIMMEOUT, but my own serice hangs at SQLConnect.Her is my code:{ rc = SQLAllocEnv (&henv); if (!RC_SUCCESSFUL(rc)) return FALSE; rc = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0); if (!RC_SUCCESSFUL(rc)) { TXTOUT("Error at SQLsetConnectAttr"); return FALSE; } bIsOpen = TRUE; rc = SQLAllocConnect (henv,&hdummy); if (!RC_SUCCESSFUL(rc)) return FALSE; rc = SQLSetConnectAttr(hdummy, SQL_ATTR_CONNECTION_TIMEOUT, (SQLPOINTER)2, 0); if (!RC_SUCCESSFUL(rc)) { TXTOUT("Error at SQLsetConnectAttr"); return FALSE; } rc = SQLConnect (hdummy,szDBName,SQL_NTS,szUser,SQL_NTS,szPasswd,SQL_NTS); if (!RC_SUCCESSFUL(rc)) { DBError (hdummy,NULL,NULL); return FALSE; } return TRUE;}Every hint will be appreciated.Tanks in advanceGregor
↧