Results 1 to 3 of 3

Thread: Connecting to a Access database through ADO.

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 1999
    Posts
    36

    Post

    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.

  2. #2
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    266

    Post

    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

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 1999
    Posts
    36

    Post

    Thank you so much.It is working!!!!!!!Yesterday I spent so many hours trying to solve the problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width