I'm at a loss why my code supplies the input parm and yet upon
execution it complains about my first input parm called @AuditItem is
not supplied. Please throw some light. Thanks

Error: ado error 2147217904 expects parameter

My stored proc
PROCEDURE [dbo].[usp_Thresholds_GetStatus]
( @AuditItem varchar(50),
@Variable varchar(250),
@ServerValue varchar(250),
@FoundFlag varchar(10) output ,
@OutputStatusCode varchar(2) output,
@OutputPrecedingMessage varchar(250) output,
@OutputMessage varchar(250) output )


My vbs code:

Set objCon = CreateObject("ADODB.Connection")
Set objCom = CreateObject("ADODB.Command")
strConnection = "Provider=SQLOLEDB.1;Password=password@1;Persist
Security Info=false;User ID=xxxtReader;Initial Catalog=mydbt;Data
Source=mysqlserver"

On Error resume next
objCon.Open strConnection
If Err.Number <> 0 Then
Wscript.Echo " Attempt to open connection to database failed"
Wscript.Echo Err.Number & " " & Err.Description
Err.Clear
End If

'assigning the command object parameters
Set objCom.ActiveConnection = objCon
objCom.CommandText = "usp_Thresholds_GetStatus"
objCom.CommandType = adCmdStoredProc
'Create in/out parameters
Set objInputAuditItemParm = objCom.CreateParameter("@AuditItem",
adVarChar, adParamInput, 50, trim(InputAuditItem))
Set objInputVariableParm = objCom.CreateParameter("@variable",
adVarChar, adParamInput, 250, trim(InputVariable))
Set objInputServerValue = objCom.CreateParameter("@ServerValue",
adVarChar, adParamInput, 250, trim(InputServerValue))

Set objOutputFoundFlag = objCom.CreateParameter("@FoundFlag",
adVarChar, adParamOutput, 10)
Set objOutputStatusCode =
objCom.CreateParameter("@OutputStatusCode", advarChar, adParamOutput,
2)
Set objOutputPrecedingMessage =
objCom.CreateParameter("@OutputPrecedingMessage", adVarChar,
adParamOutput, 250)
Set objOutputMessage = objCom.CreateParameter("@OutputMessage",
adVarChar, adParamOutput, 250)
'Append the parameters to command object
objCom.Parameters.Append objInputAuditItemParm
objCom.Parameters.Append objInputVariableParm
objCom.Parameters.Append objInputServerValue
objCom.Parameters.Append objOutputFoundFlag
objCom.Parameters.Append objOutputStatusCode
objCom.Parameters.Append objOutputPrecedingMessage
objCom.Parameters.Append objOutputMessage

on error resume next
objCom.Execute
if err <> 0 then
Wscript.Echo "Attempt to execute stored proc
usp_Thresholds_GetStatus failed"
Wscript.Echo Err.Number & " " & Err.Description
Err.Clear

end if
'retrieve the Output parameters values


WScript.Echo "Output Found flag: " & objOutputFoundFlag.value
WScript.Echo "Output Message... "
WScript.Echo objOutputMessage.value

WScript.Echo objOutputStatusCode.value

Re: Why error 2147217904 expects parameter when parm is supplied? by Joe

Joe
Sun Oct 21 03:43:06 PDT 2007

<Hoa.Hoa.Nguyen@gmail.com> wrote in message
news:1192939777.077838.261060@k35g2000prh.googlegroups.com...
> I'm at a loss why my code supplies the input parm and yet upon
> execution it complains about my first input parm called @AuditItem is
> not supplied. Please throw some light. Thanks
>
> Error: ado error 2147217904 expects parameter
>
> My stored proc
> PROCEDURE [dbo].[usp_Thresholds_GetStatus]
> ( @AuditItem varchar(50),
> @Variable varchar(250),
> @ServerValue varchar(250),
> @FoundFlag varchar(10) output ,
> @OutputStatusCode varchar(2) output,
> @OutputPrecedingMessage varchar(250) output,
> @OutputMessage varchar(250) output )
>
>
> My vbs code:
>
> Set objCon = CreateObject("ADODB.Connection")
> Set objCom = CreateObject("ADODB.Command")
> strConnection = "Provider=SQLOLEDB.1;Password=password@1;Persist
> Security Info=false;User ID=xxxtReader;Initial Catalog=mydbt;Data
> Source=mysqlserver"
>
> On Error resume next
> objCon.Open strConnection
> If Err.Number <> 0 Then
> Wscript.Echo " Attempt to open connection to database failed"
> Wscript.Echo Err.Number & " " & Err.Description
> Err.Clear
> End If
>
> 'assigning the command object parameters
> Set objCom.ActiveConnection = objCon
> objCom.CommandText = "usp_Thresholds_GetStatus"
> objCom.CommandType = adCmdStoredProc
> 'Create in/out parameters
> Set objInputAuditItemParm = objCom.CreateParameter("@AuditItem",
> adVarChar, adParamInput, 50, trim(InputAuditItem))
> Set objInputVariableParm = objCom.CreateParameter("@variable",
> adVarChar, adParamInput, 250, trim(InputVariable))
> Set objInputServerValue = objCom.CreateParameter("@ServerValue",
> adVarChar, adParamInput, 250, trim(InputServerValue))
>
> Set objOutputFoundFlag = objCom.CreateParameter("@FoundFlag",
> adVarChar, adParamOutput, 10)
> Set objOutputStatusCode =
> objCom.CreateParameter("@OutputStatusCode", advarChar, adParamOutput,
> 2)
> Set objOutputPrecedingMessage =
> objCom.CreateParameter("@OutputPrecedingMessage", adVarChar,
> adParamOutput, 250)
> Set objOutputMessage = objCom.CreateParameter("@OutputMessage",
> adVarChar, adParamOutput, 250)
> 'Append the parameters to command object
> objCom.Parameters.Append objInputAuditItemParm
> objCom.Parameters.Append objInputVariableParm
> objCom.Parameters.Append objInputServerValue
> objCom.Parameters.Append objOutputFoundFlag
> objCom.Parameters.Append objOutputStatusCode
> objCom.Parameters.Append objOutputPrecedingMessage
> objCom.Parameters.Append objOutputMessage
>
> on error resume next
> objCom.Execute
> if err <> 0 then
> Wscript.Echo "Attempt to execute stored proc
> usp_Thresholds_GetStatus failed"
> Wscript.Echo Err.Number & " " & Err.Description
> Err.Clear
>
> end if
> 'retrieve the Output parameters values
>
>
> WScript.Echo "Output Found flag: " & objOutputFoundFlag.value
> WScript.Echo "Output Message... "
> WScript.Echo objOutputMessage.value
>
> WScript.Echo objOutputStatusCode.value
>
Not sure, suggest you remove the on error resume next to see what happens.
It might be easier to read if you created and added the params as you went
along rather than create all and add all.

--

Joe Fawcett (MVP - XML)
http://joe.fawcett.name



Re: Why error 2147217904 expects parameter when parm is supplied? by Bob

Bob
Sun Oct 21 04:06:14 PDT 2007

Hoa.Hoa.Nguyen@gmail.com wrote:
> I'm at a loss why my code supplies the input parm and yet upon
> execution it complains about my first input parm called @AuditItem is
> not supplied. Please throw some light. Thanks
>
> Error: ado error 2147217904 expects parameter
>
> My stored proc
> PROCEDURE [dbo].[usp_Thresholds_GetStatus]
> ( @AuditItem varchar(50),
> @Variable varchar(250),
> @ServerValue varchar(250),
> @FoundFlag varchar(10) output ,
> @OutputStatusCode varchar(2) output,
> @OutputPrecedingMessage varchar(250) output,
> @OutputMessage varchar(250) output )
>
>
> My vbs code:
>
> Set objCon = CreateObject("ADODB.Connection")
> Set objCom = CreateObject("ADODB.Command")
> strConnection = "Provider=SQLOLEDB.1;Password=password@1;Persist
> Security Info=false;User ID=xxxtReader;Initial Catalog=mydbt;Data
> Source=mysqlserver"
>
> On Error resume next

As Joe said, this is likely masking an error that is occurring during the
creation and handling of your parameter objects. Either disable
error-handling or check the Err object after each CreateParameter statement.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"



Re: Why error 2147217904 expects parameter when parm is supplied by urkec

urkec
Sun Oct 21 11:10:01 PDT 2007

"Bob Barrows [MVP]" wrote:

> Hoa.Hoa.Nguyen@gmail.com wrote:
> > I'm at a loss why my code supplies the input parm and yet upon
> > execution it complains about my first input parm called @AuditItem is
> > not supplied. Please throw some light. Thanks
> >
> > Error: ado error 2147217904 expects parameter
> >
> > My stored proc
> > PROCEDURE [dbo].[usp_Thresholds_GetStatus]
> > ( @AuditItem varchar(50),
> > @Variable varchar(250),
> > @ServerValue varchar(250),
> > @FoundFlag varchar(10) output ,
> > @OutputStatusCode varchar(2) output,
> > @OutputPrecedingMessage varchar(250) output,
> > @OutputMessage varchar(250) output )
> >
> >
> > My vbs code:
> >
> > Set objCon = CreateObject("ADODB.Connection")
> > Set objCom = CreateObject("ADODB.Command")
> > strConnection = "Provider=SQLOLEDB.1;Password=password@1;Persist
> > Security Info=false;User ID=xxxtReader;Initial Catalog=mydbt;Data
> > Source=mysqlserver"
> >
> > On Error resume next
>
> As Joe said, this is likely masking an error that is occurring during the
> creation and handling of your parameter objects. Either disable
> error-handling or check the Err object after each CreateParameter statement.
>


Maybe he forgot to declare ADO constants.

--
urkec

Re: Why error 2147217904 expects parameter when parm is supplied? by Hoa

Hoa
Sun Oct 21 12:07:08 PDT 2007

1. I took Joe's advice and took an error -2147352571 type mismatch
on the create append
Code:
On Error resume next
Set objInputAuditItemParm = objCom.CreateParameter("@AuditItem",
adVarChar, adParmInput, 50, trim(InputAuditItem))
objCom.Parameters.Append objInputAuditItemParm
If Err.Number <> 0 Then
Wscript.Echo "Create/Add parm statement failed"
Wscript.Echo Err.Number & " " & Err.Description
Err.Clear
End If

2. When I change the code to:
On Error resume next
Set objInputAuditItemParm = objCom.CreateParameter("@AuditItem",
200, 1, 50, trim(InputAuditItem))
objCom.Parameters.Append objInputAuditItemParm
If Err.Number <> 0 Then
Wscript.Echo "Create/Add parm statement failed"
Wscript.Echo Err.Number & " " & Err.Description
Err.Clear
End If

it did not complain but it is stuck with 2147217904 expects @AuditItem
parameter which is not supplied.

3. My adoconstants are "included" as below:
Include("dbADOConstants.vbs") where include is a sub as follows:

Sub Include(sInstFile)
On Error Resume Next

Dim oFSO, f, s

Set oFSO = CreateObject("Scripting.FileSystemObject")
If oFSO.FileExists(sInstFile) Then
Set f = oFSO.OpenTextFile(sInstFile)
s = f.ReadAll
f.Close
ExecuteGlobal s
End If

Set oFSO = Nothing
Set f = Nothing
End Sub

and in the dbADOConstants.vbs file I have:
Const adParamInputOutput = &H0003
Const adParamReturnValue = &H0004

'---- CommandTypeEnum Values ----
Const adCmdUnknown = &H0008
Const adCmdText = &H0001
Const adCmdTable = &H0002
Const adCmdStoredProc = &H0004
'---- DataTypeEnum Values ----
Const adEmpty = 0
Const adTinyInt = 16
Const adSmallInt = 2
Const adInteger = 3
Const adBigInt = 20
Const adSingle = 4
Const adDouble = 5
Const adCurrency = 6
Const adDecimal = 14
Const adNumeric = 131
Const adBoolean = 11
Const adError = 10
Const adUserDefined = 132
Const adVariant = 12
Const adIDispatch = 9
Const adIUnknown = 13
Const adGUID = 72
Const adDate = 7
Const adDBDate = 133
Const adDBTime = 134
Const adDBTimeStamp = 135
Const adBSTR = 8
Const adChar = 129
Const adVarChar = 200
Const adLongVarChar = 201
Const adWChar = 130
Const adVarWChar = 202
Const adLongVarWChar = 203
Const adBinary = 128
Const adVarBinary = 204
Const adLongVarBinary = 205


Const adOpenStatic = 3
Const adLockOptimistic = 3



Re: Why error 2147217904 expects parameter when parm is supplied? by Hoa

Hoa
Sun Oct 21 12:49:09 PDT 2007

Thanks, everyone. I found out that my "include' with a file of
constants and a subroutine called include
was the culprit. I have to change it as to where every constant is
"inline" in the same file.
I had thought using "include" would help because the current calling
vbs script is already large. But the include seems to cause so "weird
behavior".
Thanks again. This is a great newsgroups - active and helpful.