vikas1111
02-21-2008, 03:41 AM
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...
Uncle Gizmo
02-21-2008, 06:16 AM
I would suggest trying a visual basic forum, I believe there are still some around!
DCrake
02-22-2008, 03:02 AM
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