Solved

OleDbCommand.ExecuteNonQuery

Posted on 2006-06-24
1
235 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

758 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

21 Experts available now in Live!

Get 1:1 Help Now