Solved

OleDbCommand.ExecuteNonQuery

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

820 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