Solved

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

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Winform Module - What is the ASP.Net equiv 2 40
JQuery Detecting page post back 6 21
C# Linq Select From List 3 50
Inserting LocalDB Table to SQL Server C# 3 23
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

696 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