?
Solved

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

Posted on 2011-02-11
4
Medium Priority
?
220 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 2000 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

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month13 days, 1 hour left to enroll

777 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