Subscribe to Subscribers
Talk to Webmaster Tony John

Online Members

baskar
More...

Forums » .NET » .NET »

inserting records through textboxes in c#


Posted Date: 20 Sep 2008      Posted By:: CRPRAJAN     Member Level: Gold    Member Rank: 939     Points: 1   Responses: 1



Can anybody provide me the code for inserting values of two fields in to sql server table through textboxes using c# winforms. The two fields are Name and Age. The datatypes of the respective fields are varchar(50) and Int. The records should be inserted using stored procedures.

Here is the stored procedure i have written

create procedure [dbo].[insertrecords]
(@Name varchar(50),
@Age int)
as
insert into emp(Name, Age) values (@Name, @Age)

Pls help me with the full c# code




Responses

#298154    Author: Mohd. Azharuddin Ansari      Member Level: Gold      Member Rank: 593     Date: 22/Sep/2008   Rating: 2 out of 52 out of 5     Points: 5

Use following lines of code for data manupulation in dot net.

string strSql=StoredProcedureName+" '"+UserNameParameter+"',"
+UserAgeParameter

SqlCommand cmd;
'Using objCon
cmd = DatabaseConnectionObject.CreateCommand();
'Using cmd
cmd.CommandType = CmdType;
cmd.CommandText = strSql;

cmd.ExecuteNonQuery()

Hope This code will help you



 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : regarding .NET Certification
Previous : Hi Need Latest .NET Certification Dumps
Return to Discussion Forum
Post New Message
Category:

Related Messages
Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
2005 - 2012 All Rights Reserved.
.NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
Articles, tutorials and all other content offered here is for educational purpose only.
We are not associated with Microsoft or its partners.