Link to home
Start Free TrialLog in
Avatar of Mikkil
Mikkil

asked on

3251 UsingVB6 and Visual Data Manager

Folks,

As part of a project, I was required to enter data into a database created by the VB6 Visual Data Manager.

What is the most striaghtforward way of accessing this using VB6, but not a Data Control.

I've tried ADO, but am getting a 3251 error (suggesting the recordset is readonly), but changing the various options only generates more errors. I'm trying looking at the MS Help - trying is the word.

Speed is of the essence.

Thanks

Mikkil

Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

ADO is the way to go.

Show your code that opens the connection and create the recordset.
Avatar of Mikkil
Mikkil

ASKER

Emoreau,

Code is :

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Sub dbload()
Set cn = New ADODB.Connection
   
    With cn
        .Provider = "Microsoft.Jet.OLEDB.4.0"
        .ConnectionString = "f:\data\p35\vbproj\vbcar\Carins.mdb"
        .Open
    End With
    Set rs = New ADODB.Recordset
    With rs
        .ActiveConnection = cn
        .Source = "Car Insurance Customer Database"
        '.CursorLocation = adUseServer
        '.CursorType = adOpenKeyset
        .Open ' , , , adLockBatchOptimistic
    End With
    With rs
        .MoveFirst
        'Populating field on load of form
        txtpolicy.Text = .Fields(Policy).Value
        txtFirstN.Text = .Fields(Fname).Value
        txtSurn.Text = .Fields(Surname).Value
        CboAddress.Text = .Fields(Address).Value
        txtAge.Text = .Fields(Age).Value
        CboCover.Text = .Fields(Cover).Value
        lblNumr.Caption = rs.RecordCount
    End With
   
End Sub

References are VB for Applications; Runtime objects and procedures; Òbjects and procedures; OLE Automation; Microsoft Access 9.0 Library; Microsoft ActiveX Data Objects 2.5 Library

3251 occurs on rs.open;

Note it also gives Invalid SQL statement on rs.open since; I'm not sure what I've changed to cause this to happen.

Thanks

Mikkil
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mikkil

ASKER

Emoreau,

Thanks .. that worked.

It's probably naive to ask, but is there a good (i.e. not a Microsoft-type-you-won't-understanding-anything-if-you-don't-already-understand-all-the-Microsoft-terminology) expanation of the whole area of connections / recordsets / source / options thing ?

Mikkil

have you check the help for all these methods and properties? You will have some explanations about them.
Avatar of Mikkil

ASKER

Emoreau,

The point I'm making is that you need to know all the terminology, otherwise you may not find the help you are looking for.

Thanks

Mikkil