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
Solved

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

Posted on 2011-02-11
4
216 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
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Set value of dynamically created checkboxlist 2 42
How to call weather service by using asmx? 4 44
transaction in asp.net, sql server 6 43
IEnumerable<T> to a List<T> 8 37
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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