Results 1 to 5 of 5

Thread: Opening a Recordset via SQL Server

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Posts
    82
    I'm working with VB6 into a SQL Server 7 database. I've been using this code to open recordsets:
    Code:
                Set objCmd = New ADODB.Command
                objCmd.ActiveConnection = PROJ_DB
                objCmd.CommandType = adCmdStoredProc
                With objCmd
                    .CommandText = "sel_candidate_where_candno_ordered"
                    .Parameters.Refresh
                    .Parameters(1) = txtSeek
                    Set rsCand = .Execute
                End With
                Set objCmd = Nothing
    The problem is, it doesn't allow for bookmarks, so populating grids, etc. are problems. There must be a way to open it as a Keyset using adOpenKeyset, such as:
    Code:
        rsCand.CursorType = adOpenKeyset
    Can anyone help me out?? Thanks...

  2. #2
    Guest
    You're on the right track...
    Add this to the end of the execute statement
    Set rsCand = .Execute(,,adOpenKeyset )

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Posts
    82
    Hey Bubba:

    Well, I tried it, but got the following error:

    "Procedure 'sel_candidate_where_candno_ordered' expects parameter @Parm1, which was not supplied"

    I think one of the commas expects parameters. Without anything there, it wipes out the Parameter(1) value. I suppose I could put a value in there, but there are other calls which require 10-20 parameters.

  4. #4
    Guest
    How 'bout this?

    [code]
    Set objCmd = New ADODB.Command
    objCmd.ActiveConnection = PROJ_DB
    objCmd.CommandType = adCmdStoredProc
    With objCmd
    .CommandText = "sel_candidate_where_candno_ordered"
    .Parameters.Refresh
    .Parameters(1) = txtSeek
    .Open
    End With

    rsCand.Open objCmd, ,adOpenKeyset, adLockReadOnly

    Set objCmd = Nothing

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Posts
    82
    Hey Bubba:

    Thanks for ll your help.

    Open is not a valid method for the Command object.

    Jeff

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