dsn connection

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

In my code i'm pointing to a SQL server name and SQL database name on the
server, etc.
Instead of that how can i point to a DSN connection on the web server that
points to the SQL Server and DB?
 
Why on earth would you want to do that? You're adding an unnecessary layer
of processing and file IO to accomplish the same thing. All a DSN does is
store information that you can put right into your Connection String. In
addition, it uses ODBC, which is a wrapper for OLE DB, and using the native
SQL Data classes is much faster.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
why do want to do want? Setup a DSN or how i'm doing it now in the code?

'Server=servername;Database=DBName"

If i keep it like it is now doesn't the SQL Server DB have to reside on the
web server? If I create a DSN who cares what servers its on, i just need to
point to a DSN on the web server.
 
<<...doesn't the SQL Server DB have to reside on the web server? >>

No - the SQL Server can exist anywhere. If you refer to it by name, then the
DNS system will resolve the name to the SQL Server's IP address;
alternatively you can specify the IP address of the SQL Server in your
connection string.
 
Here's my string

MyConnection = New
SqlConnection("server=(servername);database=issues;Trusted_Connection=yes")

is this the best way to connect in the .NET world?
In "classic asp" I always used a DSN name.

DSN=DB;UID=;PWD=;

whats the best way in .NET
 
actually that string does work, i pulled it out of my asp.net/vb.net app.
and i connect to the db just fine, but i'll check out the URL
 
why do want to do want? Setup a DSN or how i'm doing it now in the code?

Why would you want to use an ODBC DSN?

Us the native DSQL Data classes instead.

If you're having a problem formulating your Connection String, check out:
http://www.connectionstrings.com/

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
I have my connection string working fine.
The reason i was thinking of DSN is because I have ran into a scenriao that
the SQL server name changed so I had to make a change to my code then build
it back out to the server. If i had a DSN I would only have to change the
pointer of the DSN on the web server without making changes to my code then
going through our process in putting dll's/files to our web servers.

Just curious which area is beter
 
Use the native SQL classes, and put your Connection String into your
Web.Config file.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Back
Top