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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

type mismatch in function parameters 1

Status
Not open for further replies.

OhioSteve

MIS
Mar 12, 2002
1,352
US
I want certain code to execute whenever I use an ADODBcommand. To expedite this, I created a function to handle these commands. It has this signature:

Public Function useADODBcommand(myCommand As ADODB.Command)

When I test this function, I get the error "type mismatch". But I am 100 percent certain that I am passing it an ADODBcommand. What is the problem? This would be easy to do in java.
 
Steve,

Can you post the code you are calling your function from please?

Ed Metcalfe.

Please do not feed the trolls.....
 
Public Function test1()

'Create some objects and primitives.
Dim cmd As New ADODB.Command
Dim serverConn As New ADODB.Connection
Dim prmA As New ADODB.Parameter
Dim prmB As New ADODB.Parameter
Dim prmC As New ADODB.Parameter
Dim prmD As New ADODB.Parameter

'configure the parameters.
With prmA
.name = "@A"
.Type = adDate
.Direction = adParamInput
.value = "01/01/2007"
End With
With prmB
.name = "@B"
.Type = adBigInt
.Direction = adParamInput
.value = 1
End With
With prmC
.name = "@C"
.Type = adChar
.Direction = adParamInput
.Size = 20
.value = "xyz"
End With
With prmD
.name = "@D"
.Type = adBigInt
.Direction = adParamInput
.value = 2
End With

'Open the server connection.
serverConn.Open "connection string to sql server database"

'configure cmd
With cmd
.ActiveConnection = serverConn
.CommandText = "sp_upload"
.CommandType = adCmdStoredProc
.CommandTimeout = 100
.Parameters.Append prmA
.Parameters.Append prmB
.Parameters.Append prmC
.Parameters.Append prmD
End With

'execute command
useADODBcommand (cmd)

MsgBox "all done!"

End Function
 
Steve,

Remove the parenthesis from around cmd:

Code:
'execute command
useADODBcommand cmd

Ed Metcalfe.

Please do not feed the trolls.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top