Help with error

D

Darth Ferret

On the last statement below, I am getting this error -
'System.InvalidCastException'

Does anyone know what is causing this? I am trying to pass a parameter to a
stored procedure in an iseries. My connection opens and I can call a stored
procedure with no parameters. The problem is that I cannot pass any
parameters.

'create command object

Dim cmd As New iDB2Command(sql, cn

Dim cmdparm1 As New OleDb.OleDbParameter("QRYNAME", OleDb.OleDbType.Char,
10)

cmd.Parameters.Clear()

cmdparm1.Value = "SUNTR401A"

cmdparm1.Direction = ParameterDirection.InputOutput

cmd.Parameters.Add(cmdparm1)



Thanks in advance,

Joe in Florida
 
G

Guest

Darth,

Shouldn't your parameter be of type iDB2Parameter and not OleDbParameter?

And shouldn't you be using iDB2DbType.iDB2VarChar as the datatype, etc?

Kerry Moorman
 
R

RobinS

Why are you declaring the parameter as InputOutput? Are you going to read
the parameter after the query is executed?

Isn't OleDbType.Char used for a fixed-length character field; should it be
VarChar? If you have a fixed-length field, put a space on the end of your
value, because it's only 9 characters.

Is your parameter name really QRYNAME?

How are you executing the stored procedure? There's no code here showing
that.

And you're missing a parentheses on the end of the "Dim cmd as New ..."
line, but I figured that was a typo.

What does your stored procedure look like?

Robin S.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top