Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

3251 UsingVB6 and Visual Data Manager

Posted on 2002-05-01
6
Medium Priority
?
163 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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

Technology Partners: 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!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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

609 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