connecting access to vb

vikas1111

New member
Local time
Tomorrow, 04:14
Joined
Feb 21, 2008
Messages
1
Hi everybody..
I am not able to connect access to visual basic usind adodb.. Can anyone give a solution for this ????? I want to know what all settings i have to make and the coding part too...
 
Simple Software Solutions

First make sure you have ADODB referenced in your project

Next
declare the following in your start up Declarations

Public MasterDbConn As New ADODB.Connection


In your Statup Module

MasterDbConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MyMdb & ";"

MasterDbConn.CursorLocation = adUseClient

Where MyMdb is the path and name of your MDB


To use the mdb in your code use the following

Dim Tbl As New ADODB.Recordset
Set Tbl = New ADODB.Recordset
With Tbl
.Open "YourTableName", MasterDbConn, adOpenKeyset, adLockOptimistic, adCmdTable


Or


Dim rs As New ADODB.Recordset

With MasterDbConn
rs.Open "SELECT * FROM TblLoginSessions WHERE fldUserName ='" & WhoAmi & "'And fldOrganisation ='" & szOrgCode & "' ORDER BY fldLoginKey DESC ", MasterDbConn, adOpenStatic, adLockReadOnly, adCmdText

If Not rs.EOF And Not rs.BOF Then
.....
End If

rs.Close

Set rs = Nothing


The above is snapshots of my code and the table names and critieria is defined by yourself.


Code Master::cool:http://www.icraftlimited.co.uk
 
Last edited:

Users who are viewing this thread

Back
Top Bottom