Groups | Blog | Home
all groups > dotnet windows forms > november 2007 >

dotnet windows forms : ConnectionString Without DSN


Ross Culver
11/13/2007 11:18:44 AM
This is, by all accounts, a stupid question:

I've always used a connection string like this:
Data Source=DSNNAME;Initial Catalog=databasename;Persist Security
Info=True;User ID=sa;Password=pwd

I don't want to have to go to every computer and create this DSN manually.
How should the connection string read if you want to connect directly to the
sql server without specifying or creating a DSN?

Ross

Kevin Spencer
11/14/2007 7:29:56 AM
Hi Ross,

See http://www.connectionstrings.com/

--
HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP

[quoted text, click to view]

Ross Culver
11/14/2007 9:37:29 AM
Stephany and Kevin,

Thanks for the response; however, I already tried using just the server name
and I get the error that the datasource was not found. That's why I keep
creating a DSN with the same name as the server.

Ross


[quoted text, click to view]

Stephany Young
11/14/2007 1:41:44 PM
Data Source=<servername>;...

or

Data Source=<servername>\<instancename>;...



[quoted text, click to view]
Kevin Spencer
11/15/2007 7:39:45 AM
That's why I directed you to www.connectionstrings.com. Connection strings
vary from one database provider to another, and according to the type of
connection being made, and guessing at the proper format will get you
nowhere. As I don't know anything about either what database you're using,
or what the connection properties should be, I directed you to a web site
that provides all sorts of Connection Strings for all sorts of situations.

Using a System DSN is really an "ancient" technique which creates an
additional external dependency on the DSN. Look up the proper Connection
String for your needs and use that.

--
HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP

[quoted text, click to view]

Ross Culver
11/15/2007 3:26:20 PM
Kevin,

I left out one very important piece of information: I created the
connection in VS2K5 using the connection wizard using the .net framework
data provider for SQL2K5 (SQL Client); wherein you select the server by
name and never have to specify a DSN. And yet, it only works if I create a
DSN with the same name as the server.

Go figure.

Ross


[quoted text, click to view]

Jack Jackson
11/15/2007 3:29:43 PM
Maybe you will have to break down and show us what you have tried that
doesn't work.

On Thu, 15 Nov 2007 15:26:20 -0600, "Ross Culver"
[quoted text, click to view]
Kevin Spencer
11/16/2007 6:13:33 AM
The Visual Studio 2005 Connection Wizard doesn't ask for a DSN. I don't know
what you're referring to. It asks for any number of Connection String
parameters. You can also just create your own Connection String.

--
HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP

[quoted text, click to view]

AddThis Social Bookmark Button