Solved

How can I specify the size of a stored procedure parameter and also the direction

Posted on 2011-02-11
4
212 Views
Last Modified: 2012-05-11
     How can I specify the size of a stored procedure parameter and also the direction.
I'm having problems doing this......      

C# sudo code...  

 command.CommandType = CommandType.StoredProcedure;
                SqlParameter sparam = new SqlParameter("@invar",SqlDbType.Int, intput?
0
Comment
Question by:silentthread2k
  • 4
4 Comments
 
LVL 3

Accepted Solution

by:
jmro20 earned 500 total points
Comment Utility

You can do something like this:

SqlParameter[] param = {
	new SqlParameter("@ParameterName", SqlDbType.VarChar, 2),
	new SqlParameter("@ParameterName2", SqlDbType.Int),
	new SqlParameter("@ParameterName3", SqlDbType.Bit)
};

param[0].Value = ValueParameter1;
param[1].Value = ValueParameter2;
param[2].Direction = ParameterDirection.Output

Open in new window

0
 
LVL 3

Expert Comment

by:jmro20
Comment Utility
command.CommandType = CommandType.StoredProcedure;
SqlParameter sparam = new SqlParameter("@invar",SqlDbType.Int)      
sparam.Direction = ParameterDirection.Input;


//ParameterDirection has the following values avaliable: Input, InputOutput, Output and ReturnValue
0
 
LVL 3

Expert Comment

by:jmro20
Comment Utility
To specify size:
SqlParameter sparam  = new SqlParameter("@invar", SqlDbType.VarChar, 2)
0
 
LVL 3

Expert Comment

by:jmro20
Comment Utility
sparam.Size = 2;
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 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

11 Experts available now in Live!

Get 1:1 Help Now