Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Simple Question
Message
From
22/05/2002 03:03:56
 
 
To
21/05/2002 16:43:07
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00659588
Message ID:
00659757
Views:
18
1. You must use ADODB instead of ADOCE.
2. Specify path in that way: App.Path & "\SomeFile.mdb". This path refer to SomeFile in directory WHERE APPLICATION RUNS (WHERE IS .EXE). You can specify also subfolder, if you want to data are not in same folder with .exe (App.Path & "\Data\SomeFile.mdb") or specify absolute path ("C:\SomePath\SomeFile.mdb").
3. Here is sample code to open access database and bound TextBox to field:

Option Explicit
Dim cnSample As ADODB.Connection
Dim rsSample As ADODB.Recordset

Private Sub Form_Load()

Set cnSample = New ADODB.Connection
cnSample.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\BIBLIO.MDB;Persist Security Info=False"
cnSample.Open
Set rsSample = New ADODB.Recordset
rsSample.Open "SELECT * FROM Authors", cnSample
Set Text1.DataSource = rsSample
Text1.DataField = "Author"
End Sub

Private Sub Form_Unload(Cancel As Integer)

rsSample.Close
Set rsSample = Nothing
cnSample.Close
Set cnSample = Nothing
End Sub

Plamen Ivanov
MCSD .NET Early Achiever and MCAD .NET Charter Member (VB .NET/SQL Server 2000)
MCSD (VB 6.0/SQL Server 2000)

VB (.NET) - what other language do you need in the whole Universe?...

Previous
Reply
Map
View

Click here to load this message in the networking platform