Overview
Features
Download
Documentation
Community
Add-Ons & Services

ODBC SQL Server 2008 problem

Please post support and help requests here.

ODBC SQL Server 2008 problem

Postby Tamas » 25 Jul 2012, 10:55

Hi All!

I have a problem trying to connect to MS SQL Server 2008 Express via ODBC connector. I guess the connection string is what is wrong. With older versions of MS SQL servers like (2005, 2000) is working fine, but the same type of connection string doesn't work. These are the connection strings that don't work:

"Driver={SQL Server};Server=(local);Trusted_Connection=Yes;Database=Proba;"
"Server=.\SQLExpress;AttachDbFilename=e:\proba.mdf;Database=proba; Trusted_Connection=Yes;"
"Server=PCDEVELOP03\SQLEXPRESS;Database=Proba;Trusted_Connection=Yes;"
"data source=PCDEVELOP03\SQLEXPRESS;initial catalog=Proba;Trusted_Connection=TRUE;"
"Driver={SQL Server};Server=(local)\SQLExpress;Trusted_Connection=Yes;Database=Proba;"

What can I try ? The first connection string works ok with older versions of MS SQL Server. I'm building my application with VC++ 2008.
Tamas
 
Posts: 3
Joined: 25 Jul 2012, 10:43

Re: ODBC SQL Server 2008 problem

Postby alex » 26 Jul 2012, 17:39

Tamas wrote:What can I try ?

Here's a couple of ideas:
    Post some error messages so we can see what exactly went wrong.
    Google for "SQL Server 2008 connection string".
alex
 
Posts: 1044
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: ODBC SQL Server 2008 problem

Postby Tamas » 27 Jul 2012, 17:19

Thanks for reply! :D

Here are some error messages I received from exception handler paired with connection strings.

1.
connectionstring="Driver={SQL Server};Server=(local);Trusted_Connection=Yes;Database=Proba;"


Connection:NetConn: 00000000
Server:Not applicable
===========================
ODBC Diagnostic record #1:
===========================
SQLSTATE = 42000
Native Error Code = 4060
[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database requested in
login 'Proba'. Login fails.



2.
connectionstring="Server=PCDEVELOP03/SQLEXPRESS;Database=Proba;Trusted_Connection=Yes;


Connection:Not applicable
Server:Not applicable
===========================
ODBC Diagnostic record #1:
===========================
SQLSTATE = IM002
Native Error Code = 0
[Microsoft][ODBC Driver Manager] Data source name not found and no default drive
r specified



3.
connectionstring="Server=.\SQLExpress;AttachDbFilename=e:\proba.mdf;Database=proba; Trusted_Connection=Yes;"


Connection:Not applicable
Server:Not applicable
===========================
ODBC Diagnostic record #1:
===========================
SQLSTATE = IM002
Native Error Code = 0
[Microsoft][ODBC Driver Manager] Data source name not found and no default drive
r specified



4.
connectionstring="Server=PCDEVELOP03\SQLEXPRESS;Database=Proba;Trusted_Connection=Yes;"

Connection:Not applicable
Server:Not applicable
===========================
ODBC Diagnostic record #1:
===========================
SQLSTATE = IM002
Native Error Code = 0
[Microsoft][ODBC Driver Manager] Data source name not found and no default drive
r specified



5.
connectionstring="data source=PCDEVELOP03\SQLEXPRESS;initial catalog=Proba;Trusted_Connection=TRUE;"

Connection:Not applicable
Server:Not applicable
===========================
ODBC Diagnostic record #1:
===========================
SQLSTATE = IM002
Native Error Code = 0
[Microsoft][ODBC Driver Manager] Data source name not found and no default drive
r specified



6.
connectionstring="Driver={SQL Server};Server=(local)\SQLExpress;Trusted_Connection=Yes;Database=Proba;"

Connection:NetConn: 00000000
Server:Not applicable
===========================
ODBC Diagnostic record #1:
===========================
SQLSTATE = 08001
Native Error Code = 17
[Microsoft][ODBC SQL Server Driver][DBMSLPCN]SQL Server does not exist or access
denied.

===========================
ODBC Diagnostic record #2:
===========================
SQLSTATE = 01000
Native Error Code = 53
[Microsoft][ODBC SQL Server Driver][DBMSLPCN]ConnectionOpen (Connect()).

Ialso have installed older versions of MS SQL on my computer so I suppose that maybe some of the answers are from there. I'm using windows authentication mode for connecting to my databases.
Tamas
 
Posts: 3
Joined: 25 Jul 2012, 10:43

Re: ODBC SQL Server 2008 problem

Postby alex » 27 Jul 2012, 20:18

The first one would probably work if you add
Code: Select all
;User Id=YourUsername;Password=YourPassword;

But, without seeing your settings, it's hard to tell.
alex
 
Posts: 1044
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: ODBC SQL Server 2008 problem

Postby Tamas » 31 Jul 2012, 12:11

Unfortunatelly it's not working. :(

It trows this back:

Connection:NetConn: 00000000
Server:Not applicable
===========================
ODBC Diagnostic record #1:
===========================
SQLSTATE = 42000
Native Error Code = 4060
[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database requested in
login 'Proba'. Login fails.

===========================
ODBC Diagnostic record #2:
===========================
SQLSTATE = 01S00
Native Error Code = 0
[Microsoft][ODBC SQL Server Driver]Invalid connection string attribute




When I connect to database in SQL Server management studio my connection properties are:


Authentication
Authentication Method : Windows Authentication
User Name : PCDEVELOP03\borko (this line is grayed)

Connection
Database : Proba
SPID : 53
Network Protocol : <default>
Network Packet Size : 4096
Connection Timeout : 15
Execution Timeout : 0
Encrypted : No

Product
Product Name: Microsoft SQL Server Express Edition
Product Version : 10.0.2531 SP1
Server Name : PCDEVELOP03\SQLEXPRESS
Instance Name : SQLEXPRESS

... I believe other parameters are not important.
Tamas
 
Posts: 3
Joined: 25 Jul 2012, 10:43


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests

cron