Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Con"].ConnectionString);
- con.Open();
- SqlCommand cmd = new SqlCommand("sp_utmerge", con);
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Parameters.AddWithValue("@userId", Txt_Userid.Text);
- cmd.Parameters.AddWithValue("@username", Txt_Uname.Text);
- cmd.Parameters.AddWithValue("@designation", Txt_Design.Text);
- cmd.Parameters.AddWithValue("@dept", Txt_Dept.Text);
- cmd.Parameters.AddWithValue("@contact_no", Txt_Cntct.Text);
- cmd.Parameters.AddWithValue("@email", Txt_Email.Text);
- cmd.Parameters.AddWithValue("@address", Txt_Addrs.Text);
- cmd.Parameters.AddWithValue("@dob", Txt_DOB.Text);
- cmd.Parameters.AddWithValue("@password", Txt_Pwd.Text);
- cmd.ExecuteNonQuery();
- con.close();
- ALTER PROCEDURE [dbo].[sp_utmerge]@userId nvarchar(10),@username nvarchar(50),@designation nvarchar(50),@dept nvarchar(20),@contact_no nvarchar(20),@email nvarchar(MAX),@address nvarchar(100),@dob varchar(20),@password nvarchar(20)
- AS
- BEGIN
- SET NOCOUNT ON;
- merge Teachermast as target
- using (select userId, username, designation, dept, contact_no, email, address, dob, password from UserMast where usertype = 3)
- as source(userId, username, designation, dept, contact_no, email, address, dob, password)
- on target.teacher_code = source.userId
- when not matched by target then
- insert (teacher_code, teacher_name, designation, dept_code, contact_no, email, address, dob, password)
- values (source.userId, source.username, source.designation, source.dept, source.contact_no, source.email, source.address, source.dob, source.password);
- END
- USE [ABC]
- GO
- DECLARE @return_value int
- EXEC @return_value = [dbo].[sp_utmerge]
- @userId = N'T0006',
- @username = N'abc',
- @designation = N'Teacher ',
- @dept = N'EIC',
- @contact_no = N'9632563256',
- @email = N'abc@yahoo.com',
- @address = N'97 xyz street',
- @dob = N'31/08/1990',
- @password = N'12345'
- SELECT 'Return Value' = @return_value
- GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement