Results 1 to 5 of 5

Thread: Need help from a pro

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Posts
    19
    I am opening a database with the above code but need it to open "adOpenKeyset" so that the dataGrid will be editable. Opens read only forward only by default and that does me no good. Here is the code: If cboContact.Text = "Home Alone" Then
    Dim adoParameter As Parameter
    Set adoConnect = New Connection
    Set adoRecordset = New Recordset
    adoConnect.CursorLocation = adUseClient

    adoConnect.Open _
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\HomeAlone\db1.mdb;Persist Security Info=False"
    Set adoCommand = New Command
    adoCommand.CommandText = "SELECT * from qryHaContactSearch WHERE City = ?"
    Set adoParam = New Parameter
    adoParam.Name = "City"
    adoParam.Type = adVarChar
    adoParam.Size = 20
    adoParam.Value = Me.txtCity.Text
    adoCommand.Parameters.Append adoParam
    Set adoCommand.ActiveConnection = adoConnect
    Set adoRecordset = adoCommand.Execute
    Set DataGrid1.DataSource = adoRecordset
    End If

    I can't find a way to work it in so any help would be wildly appreciated. It's all I have left to finish my first big project. Thanks in advance
    Bill

  2. #2
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    Bill,

    Instead of using
    Set adoRecordset = adoCommand.Execute

    try this:

    Set adoRecordset.Source = adoCommand
    adoRecordset.CursorLocation = adUseClient
    adoRecordset.CursorType = adOpenKeyset
    adoRecordset.Open
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Posts
    19

    Talking Thanks so much!

    That worked out perfectly! I just had to add the lock type to optimistic because it's read only by default and it works! That was the last piece of a 4 month project and I thank you to no end! Your friend,
    Bill

  4. #4
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    Glad that I could help.
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  5. #5
    New Member
    Join Date
    Feb 2001
    Location
    Philippines
    Posts
    3
    Hi!
    try adding this to your code,

    adoConnect.CursorType = adOpenKeyset

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