Inserting records into a database table using a stored procedure: |
CREATE TABLE [dbo].[RegisteredClients] (
[ ClientUserName] VARCHAR (20) NOT NULL,
[MasterDistributor] VARCHAR (20) NOT NULL,);
2. Create Stored Procedure
CREATE PROCEDURE [dbo].[sp_InsertClientData]
@ClientUserName VARCHAR (20),
@MasterDistributor VARCHAR (20),
AS
Insert into RegisteredClients values
(
@ClientUserName,
@MasterDistributor,
)
RETURN 0
3. C# Code
string strConnString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
SqlConnection con = new SqlConnection(strConnString);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_InsertClientData";
cmd.Parameters.Add("@ClientUserName", SqlDbType.VarChar).Value = txtClientUserName.Text;
cmd.Parameters.Add("@MasterDistributor", SqlDbType.VarChar).Value = ddlMasterDistributor.SelectedItem.Value;
Please visit to our YouTube Channel for .net and other tech tutorial Thanks |
No comments:
Post a Comment