Re: Connect to SQL Server




"Gary Watson" <GaryWatson@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1E1C4D36-26FD-4252-899B-CF72312DBF78@xxxxxxxxxxxxxxxx
More code details.

Dim cnn As ADODB.Connection
Set cnn = New ADODB.Connection
strConnection = "Provider=SQLOLEDB.1;" & _
"Persist Security Info=False;Data Source=" & cboServers.Text & ";User
ID=" & txtUserid & _
";Initial Catalog=" & cboDatabases.Text & ";Data
Provider=SQLOLEDB.1;Password=" & txtPassword

cnn.Open strConnection ' test out login



I use:

strServer = "MyServer"
strInstance = "MyInstance"
strDB = "MyDatabase"

strConnect = "DRIVER=SQL Server;" _
& "Trusted_Connection=Yes;" _
& "DATABASE=" & strDB & ";" _
& "SERVER=" & strServer & "\" & strInstance
Set adoConnection = New ADODB.Connection
adoConnection.ConnectionString = strConnect
adoConnection.Open

If you connect to the default instance, omit the backslash and instance
name.

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


.



Relevant Pages

  • Re: Upgrading Pervasive 2000i to V9
    ... The applications that use the Btrieve API work ... > Dim cnn As ADODB.Connection ... > Dim rst As ADODB.Recordset ... > Set cnn = New ADODB.Connection ...
    (comp.databases.btrieve)
  • Upgrading Pervasive 2000i to V9
    ... I am in the process of testing our applications that currently use PSQL2000i ... Dim cnn As ADODB.Connection ... Dim rst As ADODB.Recordset ... Set cnn = New ADODB.Connection ...
    (comp.databases.btrieve)
  • Re: Update Database (mdb) script
    ... Dim cnn, dbPath, strSQL ... Set cnn = CreateObject ... "Cadstillo" wrote: ...
    (microsoft.public.scripting.vbscript)
  • Re: Looping through a table for a form
    ... Sub ADOTest() ... Dim cnn as New ADODB.Connection ... Dim rst as New ADODB.Recordset ... Set cnn = CurrentProject.Connection 'N.B. ...
    (microsoft.public.access.formscoding)