Solved

3251 UsingVB6 and Visual Data Manager

Posted on 2002-05-01
6
156 Views
Last Modified: 2010-05-02
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

0
Comment
Question by:Mikkil
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6983184
ADO is the way to go.

Show your code that opens the connection and create the recordset.
0
 

Author Comment

by:Mikkil
ID: 6983285
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
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 150 total points
ID: 6983327
change your code to:


Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Sub dbload()
Set cn = New ADODB.Connection
   
   cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=f:\data\p35\vbproj\vbcar\Carins.mdb;"

   Set rs = New ADODB.Recordset
   With rs
       .CursorLocation = adUseClient
       .CursorType = adOpenStatic
       .LockType = adLockOptimistic
       .Open "SELECT * FROM CarTable", cn
   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
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Mikkil
ID: 6983433
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

0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6983451
have you check the help for all these methods and properties? You will have some explanations about them.
0
 

Author Comment

by:Mikkil
ID: 6988760
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
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question