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
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
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
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\
.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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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-u nderstandi ng-anythin g-if-you-d on't-alrea dy-underst and-all-th e-Microsof t-terminol ogy) expanation of the whole area of connections / recordsets / source / options thing ?
Mikkil
Thanks .. that worked.
It's probably naive to ask, but is there a good (i.e. not a Microsoft-type-you-won't-u
Mikkil
have you check the help for all these methods and properties? You will have some explanations about them.
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
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
Show your code that opens the connection and create the recordset.