473,321 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Help with error

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
Jan 29 '07 #1
2 949
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
"Darth Ferret" wrote:
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
Jan 29 '07 #2

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.
---------------------------

"Darth Ferret" <no***********@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
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


Jan 29 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
5
by: xuatla | last post by:
Hi, I encountered the following compile error of c++ and hope to get your help. test2.cpp: In member function `CTest CTest::operator+=(CTest&)': test2.cpp:79: error: no match for 'operator='...
9
by: YZK | last post by:
Hello. I'm not a Web developer, just a user, and I think I may have somehow messed myself up majorly. I'm not quite sure how. Right now, javascript used by websites I go to either does not work at...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
1
by: Dave | last post by:
I am having problems accessing DTS after install SP4 and was wondering if someone could offer some advice. I installed SP4 and got the following error after it competed. Unable to write to...
6
by: Jax | last post by:
I have Visual Studio 2002 Standard Edition. It has been working fine up to a point and now i'm at that point. Due to the limitations of the edition i am not using any of my own .dll's and instead...
5
by: Marc Violette | last post by:
<Reply-To: veejunk@sympatico.ca> Hello, I'm hoping someone can help me out here... I'm a beginner ASP.NET developper, and am trying to follow a series of exercises in the book entitled...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
12
by: =?Utf-8?B?ZGdvdw==?= | last post by:
I designed a "contact_us" page in visual web developer 2005 express along with EW2 after viewing tutorials on asp.net's help page. Features work like they should, but I cannot figure out how to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.