C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




stored procedure calling into application


Posted Date: 03 Jun 2008    Resource Type: Code Snippets    Category: ADO.NET

Posted By: subramanyam       Member Level: Silver
Rating:     Points: 3



Create one table named emp
Write the stored procedure for the insertions of the table as


Create procedure insert_emp(@eid int,@ename varchar(20) as
Begin
Insert into emp values(@eid,@ename);
End


After that in the application write the following code


{
SqlConnection cn = new SqlConnection();//here in the bracket write the sqlserver address
cn.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "INSERT_EMP";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = cn;
cmd.Parameters.AddWithValue("@eid", TextBox1.Text);
cmd.Parameters.AddWithValue("@ename", TextBox2.Text);
cmd.executenonquery();
cn.close();

}




Responses

Author: Kapil Dhawan    17 Jun 2008Member Level: Gold   Points : 2
Hello
Nice piece of code
Thanks for sharing your knowledge with us.
I hope to see more good code from your side
This code is going to help lots of guys.
Ton Thanks to you
Regards,
Kapil



Author: Bunty    03 Sep 2008Member Level: Diamond   Points : 1
Hi,

Nice code.
Clearly explain how to call a stored procedure from a .net application.
Easy to understand.
Keep posting such useful code.

Thanks and Regards
S.S.Bajoria


Author: bob    04 Sep 2008Member Level: Silver   Points : 0
nice code,very easy to understand


Author: Roopesh Babu Valluru    05 Sep 2008Member Level: Gold   Points : 0
good post man...


Author: vijaybabu    05 Sep 2008Member Level: Silver   Points : 0
nice one
sure this will help me.
Thanks Man


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

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: SavePoint of Transaction in ADO.Net
Previous Resource: How to pass value from one form to another form
Return to Discussion Resource Index
Post New Resource
Category: ADO.NET


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

web conferencing

Contact Us    Privacy Policy    Terms Of Use