C++ [ODBC]-MSSQLExpress 2008 SQLSTATE: 28000 || 42000

235 Views Asked by At

I'm facing some issues trying devloping a program that has to get informations from database and tables created under MSSQL 2008 management. I have to admit that I'm new to ODBC... If anyone could help me with this issues? I tried two solutions to connect to my database [CodeA] and [CodeB]. I found documentation on google and tried a couple of solutions but until now can't find the right one. Please have a look at my connection string below.

CodeA:

SQLDriverConnect (sqlconnectionhandle,NULL,
(SQLCHAR*)TEXT("DRIVER={SQL Server};SERVER=TOWER-PC\\SQLEXPRESS;DATABASE=tfe;UID=adminA;PWD=@Admin1;IntegratedSecurity=SSPI;"),
SQL_NTS,retconstring,1024,NULL,SQL_DRIVER_NOPROMPT)

CodeB:

SQLDriverConnect (sqlconnectionhandle,NULL,
(SQLCHAR*)TEXT("DRIVER={SQL Server};SERVER=TOWER-PC\\SQLEXPRESS;DATABASE=tfe.mdf;UID=adminA;PWD=@Admin1;Trusted_Connection=Yes;"),
SQL_NTS,retconstring,1024,NULL,SQL_DRIVER_NOPROMPT)

CodeC:

SQLDriverConnect (sqlconnectionhandle,NULL,
(SQLCHAR*)TEXT("DRIVER={SQL Server};SERVER=TOWER-PC\\SQLEXPRESS;DATABASE=tfe.mdf;Trusted_Connection=Yes;"),
SQL_NTS,retconstring,1024,NULL,SQL_DRIVER_NOPROMPT)

The SQLSTATE that is returned from the execution. SQLSTATE While this are the roles attributed to my user: User roles

1

There are 1 best solutions below

0
On BEST ANSWER

Solution

I solved this problem by modifying the connection string to:

"DRIVER={SQL Server};SERVER=TOWER-PC;DATABASE=tfe;UID=adminA;PWD=@Admin1;"

Helpful link