Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to get cmd.parameters to work 2

Status
Not open for further replies.

TommyTea

Programmer
Nov 7, 2002
43
US
My first adp project.

I have the following proc:

Public Sub TestIt()
Dim cnn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim p1 As Parameter, p2 As Parameter, p3 As Parameter, p4 As Parameter

Set cnn = CurrentProject.Connection
Set cmd.ActiveConnection = cnn
cmd.CommandText = "dbo.ud_add_tracking_record"
cmd.CommandType = adCmdStoredProc

Set p1 = cmd.CreateParameter("Employee", adSmallInt, adParamInput)
cmd.Parameters.Append p1
p1.Value = [Forms]![frmTest].[cmbEmployee]

cmd.Execute

End Sub

It stops on the Set p1 line and tells me that there is a type mismatch. I cannot figure out what it is complaining
about. I have the ActiveX Data Objects 2.6 Library loaded.
 
You don't use Set.

Does the stored procedure already have parameters ? If so, all you need to do is something like ths:

cmd.Parameters(1).Direction = adParamInput
cmd.Parameters(2).Direction = adParamInput
cmd.Parameters(1).Value = myStr1
cmd.Parameters(2).Value = myStr2

(This example has 2 parameters)



 
For future reference, your syntax does look correct. Possibly ADO is interrogating your stored procedure and finding that the first parameter in the list is not a small integer.
Another possibility is that there is a DAO reference which also has a parameter object and this reference is the first in the references list.
This would fix.
Dim p1 as ADODB.Paramter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top