Click to See Complete Forum and Search --> : ADO Connectivity


Arunesh
August 4th, 1999, 03:35 AM
Hi
I am new VB , I am doing Database work using ADO in VB, I want some Sample which help to start. Any one could suggest a good book as well as send some good sample codes .

thanks in advance
cheers
Arunesh

SparowHawk
August 4th, 1999, 07:22 PM
Here's a sample ....
In a .bas module:

public conn as new ADODB.Connection
public rsRecordset as new ADODB.Recordset

public Sub OpendB()

set conn = new ADODB.Connection
set rsRecordset = new ADODB.Recordset
With conn
.Provider = "Microsoft.jet.oledb.3.51"
.Open App.Path & "\MyDatabase.mdb"
End With

rsRecordset.Open SQLStatment, conn, adOpenStatic, adLockOptimistic

End Sub

public Sub ClosedB()

rsRecordset.Close
conn.Close

End Sub




I chose an Jet style database to open the connection to as the provider. Different ones require different syntax but mdb's seem to be the most common.

You can address the opened recordset like this:
rsRecordset.MoveFirst etc and set/retrieve a field like rsRecordset!FieldName

Don't forget to include Microsoft ActiveX Data Object 2.0 Library in your Project References and possibly Microsoft ADO Data Control 6.0 (OLEDB) as a component.

Hope this helps a bit