PDA

Click to See Complete Forum and Search --> : Connecting to a Access database through ADO.


Anita
Nov 18th, 1999, 04:05 AM
I have declared the following in a bas module.

Public cnMainData As Connection
Public rs As Recordset

Then in the form load event I wrote

Set cnMainData = New Connection
Set rs = New Recordset
With cnMainData
.Provider = "Microsoft.Jet.OLEDB.3.51"
.ConnectionString = "c:\Anita\db1.mdb"
.Open
End With
With rs
.Open "Employer", cnMainData, adOpenDynamic
.AddNew
!CompanyName = Text1.Text
!Vocation = Text2.Text
!ContactPerson = Text3.Text
!Address = Text4.Text
!city = Text5.Text
!ZipCode = Text6.Text
!Phoneno = Text7.Text
!FaxNo = Text8.Text
!EmailId = Text9.Text
!PreviousPlacements = Text10.Text
.Update
End With
It is giving a run-time error 3251
for rs.addnew.
" The operation required by the application is not supported by the provider.
If I declare
Public cnMainData As ADODB.Connection
Public rs As ADODB.Recordset
it is giving the same result.

msdnexpert
Nov 18th, 1999, 10:45 AM
You have opened the recordset in the default locking mode i.e. read only mode. Therefore you are unable to add records to it.
Instead of this
.Open "Employer", cnMainData, adOpenDynamic
try this
.Open "Employer", cnMainData, adOpenDynamic,adlockoptimistic
It will work

Anita
Nov 18th, 1999, 07:08 PM
Thank you so much.It is working!!!!!!!Yesterday I spent so many hours trying to solve the problem.