Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Remote connection DSN issue

Author  Topic 

drh3010
Starting Member

18 Posts

Posted - 2008-01-09 : 14:53:43
Error is: "Unable to open database. Data source name not found and no default driver specified"

From what I've read, this is a DSN issue. This happens when we try to connect to the SQL Server on a clean XP install. Our application is developed using MFC (CDatabase class).

Is it possible to create a DSN without using the ODBC Data Source Administrator tool? And do I need to add DSN=WhateverICallit to the connection string?

stowellg
Starting Member

9 Posts

Posted - 2008-01-09 : 15:14:43
Its been a while since I've done any ODBC work - but I always used DSN,UID and PWD in clear text when creating an ODBC connection.

Horrible for security since it was all in clear text, but all of my code sat on the server itself, which had a tight permissions list, so the only people who could see it already had admin rights on the server and logins as well.

So I would suggest adding the DSN to the connection string if you havent already. When you created the ODBC data source, did you click "Test data source" or whatever that button is after you finished creating it?

Lastly - the DSN needs to be created on whatever machine is running the code - so if it works fine on your machine, you still need to create the DSN wherever you deploy it (or at least you used to - its been a while).

I haven't found a way to add the DSN without the tool - so if anyone has a suggestion here, I'd be interested as well.

I have a stupid question for you...
Go to Top of Page

drh3010
Starting Member

18 Posts

Posted - 2008-01-09 : 15:40:32
I should add that if SQL Server Express is installed on the client machine, our application can connect to the remote server.

It's only when SQL Server isn't installed (clean XP machine) that the error happens.

So this connection string works when SQL Server is installed on the client machine:
"Driver={SQL Native Client};Server=HOST\\INSTANCE;Database=dbname;Uid=loginname;Pwd=password"
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-01-09 : 22:13:01
You need sql client installed if you use sql native client.
Go to Top of Page

drh3010
Starting Member

18 Posts

Posted - 2008-01-09 : 23:57:22
quote:
Originally posted by rmiao

You need sql client installed if you use sql native client.



Thanks! I'll try that. Can I change the driver to something besides {SQL Native Client} in the connection string and not install SQL Client?
Go to Top of Page

drh3010
Starting Member

18 Posts

Posted - 2008-01-10 : 10:34:43
Yep that worked. Download and install sqlncli.msi and this problem is fixed.
Go to Top of Page
   

- Advertisement -