Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2003

    Unanswered: ADO Command Property - Pass Parameter

    I am running Access 2000 with SQL Server. Before switching to ADO from DAO, I was able to Open a recordset built on parameter input and then add new records as well as update the records within that recordset. I'm assuming the only way to do this in ADO, is to use the Command property since I'm dealing with Parameters. The following code will not let me Add new records.
    Set Rst1 = New ADODB.Recordset
    Set Cmd1 = New ADODB.Command
    Cmd1.ActiveConnection = Comm1
    Cmd1.CommandText = "sp_Test"
    Cmd1.CommandType = adCmdStoredProc
    Set Parm1 = Cmd1.CreateParameter("@ZDate", adDate, adParamInput)
    Parm1.Value = ZDate
    Cmd1.Parameters.Append Parm1
    Set Parm1 = Nothing
    Set Rst1 = Cmd1.Execute()
    Do I need to open another recordset referencing the Table? Also, if I just want to Requery the recordset leaving the Parameters unchanged, is that possible, or do I need to send another Command? Help would be appreciated. Thanks.

  2. #2
    Join Date
    Apr 2003
    It look likes you still using DAO in some of the code. I usually use ADO because it newer and I dont' know much about DAO. Anyways, this is how I would add new record to a table.

    Table Name: Students(FirstName, LastName, Grades)

    Dim conndb as ADODB.Connection
    Dim rsStudents as ADODB.Recordset

    Set conndb = CurrentProject.Connection
    Set rsStudents = New ADODB.Recordset

    rsStudents.Open "Students", conndb, adOpenkeyset, adLockPessimistic, adCmdTable

    rsStudents("FirstName") = "Al"
    rsStudents("LastName") = "Pacino"
    rsStudents("Grades") = "B+"

    That's it. I hope this help for some of your code your doing. maybe manipulate mines and put it in yours.
    Last edited by lansing; 07-22-03 at 11:46.

  3. #3
    Join Date
    Jun 2003
    Found the problem to be the FIND method as in ADO it does not allow for multiple criteria searches.

Posting Permissions

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