ASP Hosting sale!
1,000MB space, 40GB transfer, 1 SQL Server 2000 db! - $9.95 per month*!
Limited Time Offer!

aspdev | articles | tutorials | forums

ASPdev -> ASP Articles -> How to connect to MS SQL Server database from ASP?

How to connect to MS SQL Server database from ASP?

Before you can access your MS SQL Server database from ASP, you need to connect to it using one of the following methods:

1. Connect to a MS SQL Server database with OLE DB:

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Provider=SQLOLEDB; Data Source=YOUR_SERVER_NAME; Initial
Catalog=your_database_name; User ID=your_username; Password=your_password"
objConn.Close
Set objConn = Nothing

2. Connect to a MS SQL Server database with SQL Driver:

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Driver={SQL Server};" & _
"Server=YOUR_SERVER_NAME;" & _
"Database=your_database_name;" & _
"Uid=your_username;" & _
"Pwd=your_password;"
objConn.Close
Set objConn = Nothing




Contact Us