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

Having trouble with an Access query

Status
Not open for further replies.

jewel464g

Technical User
Jul 18, 2001
198
US
Hello folks. Having a little trouble with a .dll and I don't know what the problem is. I am new to this stuff, so I am probably looking over something really simple. I appreciate any help.

dave

Here is the code. I am calling a query in an Access database which uses a parameter(strMessageID) to get a single value from the database, which I am storing in UpdateDB. I am not too sure about the "createparameter" part of the code...probably is part of the problem.

Public Function UpdateDB(ByVal strDbConnectionString As String, ByVal strSQL As String, ByVal strMessageID As String) As Variant

Dim oRs As New ADODB.Recordset
Dim oCmd As New ADODB.Command
Dim oConn As New ADODB.Connection
Dim Parm As Parameter
oConn.Open strDbConnectionString
oCmd.CommandText = strSQL
oCmd.CommandType = adCmdStoredProc
Set oCmd.ActiveConnection = oConn
Set Parm = oCmd.CreateParameter("variableID", adIUnknown, adParamInput, Len(strMessageID), strMessageID)
Param1.Value = strMessageID
Call oCmd.Parameters.Append(Parm)
Set Parm = Nothing
Set oRs = oCmd.Execute()
UpdateDB = oRs.getRows
oRs.Close
oConn.Close
Set oRs = Nothing
Set oCmd = Nothing
Set oConn = Nothing

End Function


I get the error message below. I am running this as a .dll from an ASP page.

Error Type:
ADODB.Command (0x800A0D5D)
Application uses a value of the wrong type for the current operation.






 
Rather then creating a parameter variable, try:
oCmd.Parameters.Append oCmd.CreateParameter("@variableID", adVarChar, adParamInput, 50, strMessageID)

If you know the datatype of the parameter use it rather then adIUnknown
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top