?
Solved

3251 UsingVB6 and Visual Data Manager

Posted on 2002-05-01
6
Medium Priority
?
158 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 600 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

764 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