by Abhijit Desai (3 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 7th June 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Opening DSNless connection in Access, SQL Server & Oracle
'* 1. USING ODBC DRIVERS
Dim con As New ADODB.Connection
con.Open "Driver={Microsoft Access Driver (*.mdb)}; dbq=Biblio.mdb; DefaultDir=C:\Program Files\Microsoft Visual Studio\VB98; uid=admin; pwd="
Print "Access connection state=" & con.State
con.Close
con.Open "Driver={Oracle ODBC Driver}; dbq=beq-local.world ;uid=scott; pwd=tiger"
Print "Oracle connection state=" & con.State
con.Close
'Note: This connection is tested on both Personal Oracle 8 and Oracle 8i. Only change you make while using it with oracle8i client is to use Net 8 service name as value of dbq parameter.
con.Open "Driver={SQL Server}; Server=Server1; Database=pubs; uid=sa; pwd="
Print "SQL Server connection state=" & con.State
con.Close
'* 1. USING OLEDB PROVIDERS
con.Open "Provider=Microsoft.Jet.Oledb.4.0; Data Source=C:\Program Files\Microsoft Visual Studio\VB98\Nwind.mdb; User Id=admin; Password="
'Note: connectionstring in above example makes use of provider for Access 2000 database. For earlier version of database use Provider=Microsoft.Jet.Oledb.3.51
con.Open "Provider=MSDAORA.1;Password=tiger;User ID=scott;Data Source=beq-local.world"
con.Open "Provider=SQLOLEDB.1;User ID=sa;password=;Data Source=(local); Initial Catalog=Northwind"