ASP to MSSQL connection

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

Connect to a MS-SQL Server database with MS-SQL Driver:

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

 

Remeber to change the (SERVERNAME) to match your connection string
for example if you mssql hostname is:   sqlserver.webhost4asp.com,777

then you have to change the string from
Server=(SERVERNAME);
to
Server=sqlserver.webhost4asp.com,777;

  • 46 Users Found This Useful
Was this answer helpful?

Related Articles

I get an error 'Server.CreateObject Failed' when I try to use CDONTs. What can I do?

CDONTs is no longer supported on Windows 2003 server.  Microsoft introduced CDO back several...

Do you allow custom COM components?

Yes, we do allow Custom Components and we have to charge setup fee for your COM Components...

How do I send email from ASP using SMTP Authentication?

Please note that our mail server is configured with Authentication. Below is the code snippet...

After I configure the custom error setting in the control panel, I still get the generic error page?

Custom error setting is a web server setting that sets your website Error Pages, but you can...

ASP.NET Validation is not working on your server

For ASP.net validation such as Required Field Validator,Compare Validator to work properly,...