I need some help with connecting to a SQL DB. From what I understand I
use something like this:

Dim RS
Dim CN

Set cn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")

objConnection.Open "Provider = Microsoft.Jet.OLEDB.4.0; Data Source
=C:\Online_Database\FE\Deadline DB.mdb;"

But the last line should be for an SQL DB not an access one. I know
this is a newbie question, but that is what I am! :)

Thanks

Re: Help connecting to SQL DB by Richard

Richard
Thu Jan 26 12:15:39 CST 2006

blinky44 wrote:

>I need some help with connecting to a SQL DB. From what I understand I
> use something like this:
>
> Dim RS
> Dim CN
>
> Set cn = Server.CreateObject("ADODB.Connection")
> Set rs = Server.CreateObject("ADODB.Recordset")
>
> objConnection.Open "Provider = Microsoft.Jet.OLEDB.4.0; Data Source
> =C:\Online_Database\FE\Deadline DB.mdb;"
>
> But the last line should be for an SQL DB not an access one. I know
> this is a newbie question, but that is what I am! :)

Hi,

I use code similar to:
=========================
strDB = "TestDB"
strInstance = "MyInstance"
strConnect = "DRIVER=SQL Server;" _
& "Trusted_Connection=Yes;" _
& "DATABASE=" & strDB & ";" _
& "SERVER=" & strServer & "\" & strInstance
objConnection.ConnectionString = strConnect
objConnection.Open
========================

If you are using the default instance, it would be:

strConnect = "DRIVER=SQL Server;" _
& "Trusted_Connection=Yes;" _
& "DATABASE=" & strDB & ";" _
& "SERVER=" & strServer

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net



Re: Help connecting to SQL DB by Michael

Michael
Thu Jan 26 21:19:04 CST 2006

>> objConnection.Open "Provider = Microsoft.Jet.OLEDB.4.0; Data Source
>> =C:\Online_Database\FE\Deadline DB.mdb;"
>>
>> But the last line should be for an SQL DB not an access one. I know
>> this is a newbie question, but that is what I am! :)

For future reference, one of the more comprehensive (IMO) of many sites with
connection string examples...

Connection Strings
http://www.carlprothman.net/Default.aspx?tabid=81

--
Michael Harris
Microsoft MVP Scripting