C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » SQL »

How to Execute Stored Procedure


Posted Date: 26 Oct 2009    Resource Type: Code Snippets    Category: SQL
Author: Shunmuganathan MMember Level: Diamond    
Rating: 1 out of 5Points: 5



Description :


The following code is used for execute a Stored procedure


SqlConnection MySqlConnection = new SqlConnection("Connection String");
SqlCommand MySqlCommand = new SqlCommand("MySP", MySqlConnection);
MYSqlCommand.CommandType = CommandType.StoredProcedure;
SqlParameter MySqlParameter = new SqlParameter("@Value1", SqlDbType.Int);
MYSqlCommand.Parameters.Add(MySqlParameter);
MYSqlCommand.Parameters.Add("@Value2", SqlDbType.Int);
MYSqlCommand.Parameters.Add("@Value2", SqlDbType.Int).Direction = ParameterDirection.Output;
SqlDataAdapter MySqlDataAdapter = new SqlDataAdapter(MYSqlCommand);


Code Explanation

1. Create the SqlConnection
2. CReate a SqlCommand object
3. Add the parameters
I showed different type and way of add the parameters
4. Useing the SqlDataAdapter execute the SP

By
Nathan



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Stored procedure in sql server  .  Stored Procedure  .  Sql server  .  Execute stored procedure  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: SQL, Select values as CSV in output paramter
Previous Resource: How to get integer value from float data
Return to Discussion Resource Index
Post New Resource
Category: SQL


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use