Friday, February 10, 2012

Best way to connect to a MSSQL database

Hello,

Is it better to use a DSN connection or using a connection string Set Connection = Server.CreateObject("ADODB.Connection")

Which is easier to use and more reliable?

Also could I have all the connection info on one page and then just include it with a include statment everytime I need to query the database??

Thank you,


Rich


Are you using classic ASP or ASP.NET? The first has pages ending in .asp, and the second ends with .aspx.

In either case, DSNs and ODBC are discouraged.

For Sql Server 2000, look here:http://www.connectionstrings.com/?carrier=sqlserver, and for 2005, here:http://www.connectionstrings.com/?carrier=sqlserver2005

|||

I am learning classic ASP and then will learn ASP.NET

Why are DSNs and ODBC discouraged...

I was looking at the websites you gave me.. then are all saying .NET... will classic ASP work too??

Rich

|||

for Classic ASP i would recommend using DSN and ODBC as you can use any database with this kind of connections with smaller changes.

you can place your connection in a page called connection.asp which then you will need to inlcude at the top of each page. for sample check out this:

http://www.codeproject.com/database/connectionstrings.asp

but for ASP.NET its provides its own Provider for different database which makes its easy to control the database and are faster and more releiable then ODBC.

thanks

|||

Frankly, I would go straight to ASP.NET. It has replaced classic ASP. There's a newsgroup for classic ASP over at microsoft.public.inetserver.asp.general (which you can get to through Google Groups). There used to be thousands of posts a month there. No there are just one or two per day. Classic ASP will not be developed any further. The only reason that people generally use it these days is because they have existing apps that were written in classic ASP that they want to maintain.

ODBC is deprecated technology. DSNs make use of ODBC. They cause unnecessary overhead and maintenance. For classic ASP, you should use OLEDB.

http://databases.aspfaq.com/database/what-should-my-connection-string-look-like.html

No comments:

Post a Comment