tweak of A2002 Enterprise Dev Handbook fails?



I'm tweaking the example on page 240-1 of book... I'm reading from an
Access DB... what's weird is that the create/append parameter part
seems to be ignored. Here's my tweaked code:

Public Sub GetTasks()
'Execute a stored procedure
'without parameters
'that returns records.

Dim cnn As ADODB.Connection
Dim cmd As ADODB.Command
Dim rst As ADODB.Recordset
Dim prm As ADODB.Parameter

Set cnn = CurrentProject.Connection
Set cmd = New ADODB.Command
Set rst = New ADODB.Recordset

Set cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = "sp_ActiveSkills"
cmd.CommandType = adCmdStoredProc

' Create the paramater and append it to
' the Command object's Parameters collection.
Set prm = cmd.CreateParameter("WeekendNo", adInteger,
adParamInput, , 1)
cmd.Parameters.Append prm

' Execute the command and place results
' in Recordset object
Set rst = cmd.Execute()

If Not rst.EOF Then
Do Until rst.EOF
Debug.Print rst.Fields(0), rst.Fields(1)
rst.MoveNext
Loop
Else
Debug.Print "recordset contains no records"
End If

rst.Close
Set prm = Nothing
Set rst = Nothing
Set cmd = Nothing
Set cnn = Nothing

End Sub

The only significant differences are that I passed a value in the
CreateParameter line, and omitted the argument. (because it wasn't
working).

What's totally weird is that I get ALL the results back (i.e. an
unfiltered recordset), instead of just the ones I want (for weekNo=1.
Is it something I'm doing wrong? I figured ADH stuff would work
great, but for some reason, this returns weird values. Is it because
I'm not talking to SQL Server, but Access? (but I thought that was the
point of ADO - to generalize the connection to a datastore... huh???)

Thanks!
Pieter

.



Relevant Pages

  • Re: tweak of A2002 Enterprise Dev Handbook fails?
    ... Set rst = New ADODB.Recordset ... system stored procedure, leading it to look for it in the Master database ... Set prm = cmd.CreateParameter("WeekendNo", adInteger, ... Execute method creates a NEW recordset object with default properties and ...
    (microsoft.public.data.ado)
  • Re: Exporting data from an append table into excel without field h
    ... this is the most simple code to export to excel using copy from recordset. ... Dim objXLApp As Object 'Excel.Application ... Set rst = CurrentDb.OpenRecordset ... Set objXLWs = objXLWb.Worksheets ...
    (microsoft.public.access.externaldata)
  • Re: A command button (Access) that saves the current record in a file
    ... 'In the onclick event of command button ... Dim fso As New FileSystemObject ... Set rst = Me.frmTextFileDemoSub.Form.RecordsetClone ... 'set recordset object rst to current record ...
    (microsoft.public.access.externaldata)
  • Re: Excel ADO Crash
    ... One other important point: the recordset ... Dim cnt As New ADODB.Connection ... Set cnt = New ADODB.Connection ... Set rst = New ADODB.Recordset ...
    (microsoft.public.excel.programming)
  • Re: Booking System - Vacant room report
    ... in what format? ... within the date range as a field in the recordset, ... Dim colDates As Collection ... Set rst = CurrentDb.OpenRecordset ...
    (comp.databases.ms-access)