Solved

OleDbCommand.ExecuteNonQuery

Posted on 2006-06-24
1
237 Views
Last Modified: 2012-06-27

I'm getting an error ("String[1]:  the Size property has an invalid size of 0.") when executing the OleDbCommand.ExecuteNonQuery method.  The stored proc involved has 4 parameters, 2 input and 2 output.  I've executed the proc in isql and verified that it behaves.  I've stepped through the following C# code and verified the contents of the OleDbCommand object prior to the method call (the 4 parameters are in the right order, the output parms have the correct type, and the input parms have valid values).  Does anyone know what Size property is referred to in the error message?

            // Set output parameter types
            _oDbTypes = GetDbTypes();
            for (int i = 0; i < _oDbTypes.Length; i++)
            {
                OleDbParameter outParm = new OleDbParameter();
                outParm.Direction = ParameterDirection.Output;
                outParm.OleDbType = _oDbTypes[i];
                command.Parameters.Add(outParm);
            }

            // Set input parameter values
            for (int i = 0; i < _oInParmValues.Length; i++)
            {
                OleDbParameter inParm = new OleDbParameter();
                inParm.Value = _oInParmValues[i];
                command.Parameters.Add(inParm);
            }
            command.Connection = _conn;
            command.ExecuteNonQuery();

jkavx
0
Comment
Question by:jkavx
1 Comment
 
LVL 30

Accepted Solution

by:
Alexandre Simões earned 500 total points
ID: 16976841

Hi!
You never specify the parameter Size, that must be the problem.
For example, if the parameter's type is SqlType.Int, its size must be 4, numericPrecision 10 and a numeric scale 0 (zero).

Take a look at you r table an see each column properties, then set the right values to each one, your problem should desapear.

Alex :p
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now