[AccessD] HELP! Access97 passthrough query to SQL

Jeanine Scott jscott at mchsi.com
Wed Feb 4 19:23:01 CST 2004


Anyone know how to set a connection string for a passthrough query in
code? I can easily run my passthrough using a dsn but I can’t find out
how to build it without a dsn. It is not an option for me to use a dsn
and I don’t want to hardcode the connection string because I want to
easily switch databases (test to production, etc).
 
I am using a dsnless connection with NT Authentication. I’ve included
the connection code below.
 
 
Thank you!!!!
 
 
 
If gOcon.State = adStateOpen Then
    Exit Sub
End If
 
If IsEmpty(gvarSQLDataLocation) Then
    gvarSQLDataLocation = GetLocationINI("PathTestHome")
End If
 
'open the sql connection
With gOcon
    
    .ConnectionTimeout = 5000
    .CommandTimeout = 5000
    .CursorLocation = adUseServer
    '.Provider = "Microsoft.Jet.OLEDB.3.51"
    .Provider = "SQLOLEDB"
    
    'NT Authentication
    '.ConnectionString = "Provider=SQLOLEDB " & _
                        "Data Source=" & gvarSQLDataLocation & " " & _
                        "Initial Catalog=" & gstrDBName & " " & _
                        "Integrated Security=SSPIPersist Security
Info=False"
    'with
    .ConnectionString = "Data Source=" & gvarSQLDataLocation & ";" & _
                        "Integrated Security=SSPI;Persist Security
Info=False"
    'CMK End
    'Works with SQL Auth
   '.ConnectionString = "Provider=SQLOLEDB " & _
                        "Data Source=" & gvarSQLDataLocation & " " & _
                        "Initial Catalog=" & gstrDBName & " " & _
                        "User ID=Paruser " & _
                        "Password=Paruser"
    
    .Open
 
    .DefaultDatabase = gstrDBName
End With
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.574 / Virus Database: 364 - Release Date: 1/29/2004
 


More information about the AccessD mailing list