Database Structure
Simple stored procedure for insert.
- create procedure insert_userdetail
- (
- @Username varchar(50),
- @Password varchar(50),
- @Address varchar(120),
- @Mobile varchar(12),
- @Email varchar(50)
- )
- as
- insert into tbl_ins values(@Username,@Password,@Address,@Mobile,@Email)
Userdetails.aspx.cs
Code:
- protected void btnins_Click(object sender, EventArgs e)
- {
- SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings[“userconnstring”].ConnectionString);
- SqlCommand cmd = new SqlCommand(“insert_userdetail”, con);
- cmd.CommandType = CommandType.StoredProcedure;
- con.Open();
- cmd.Parameters.AddWithValue(“@Username”, txtusername.Text);
- cmd.Parameters.AddWithValue(“@Password”, txtpassword.Text);
- cmd.Parameters.AddWithValue(“@Address”, txtaddress.Text);
- cmd.Parameters.AddWithValue(“@Mobile”, txtmob.Text);
- cmd.Parameters.AddWithValue(“@Email”, txtemail.Text);
- cmd.ExecuteNonQuery();
- alert.Text = “User Inserted Successfully!”;
- con.Close();
- }
Screen 1
Screen 2:[Database
No comments :
Post a Comment