Solved

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

Posted on 2011-02-11
4
218 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
4 Comments
 
LVL 3

Accepted Solution

by:
jmro20 earned 500 total points
ID: 34873066

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
ID: 34873104
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
ID: 34873135
To specify size:
SqlParameter sparam  = new SqlParameter("@invar", SqlDbType.VarChar, 2)
0
 
LVL 3

Expert Comment

by:jmro20
ID: 34876520
sparam.Size = 2;
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

729 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