using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Data; using System.Data.SqlClient; using System.Web.UI.WebControls; public partial class Register : System.Web.UI.Page { SqlConnection con; SqlCommand command; SqlDataAdapter sda; protected void Page_Load(object sender, EventArgs e) { } protected void txtsubmit_Click(object sender, EventArgs e) { string register_id = txtReg_id.Text; string name = txtName.Text; string contact = txtcontact.Text; con = new SqlConnection("Data Source=TUSHAR\\SQL;Initial Catalog=clrroom;Integrated Security=True"); con.Open(); try { string insertq = "insert into Register(Registration_id, Name,Contact,Role)"+ "values(@Registration_id,@Name,@Contact,@Role)"; command = new SqlCommand(insertq,con); command.Parameters.Add("@Registration_id",SqlDbType.VarChar).Value=txtReg_id.Text.Trim(); command.Parameters.Add("@Name",SqlDbType.VarChar).Value=txtName.Text.Trim(); command.Parameters.Add("@contact",SqlDbType.VarChar).Value=txtcontact.Text.Trim(); command.Parameters.Add("@Role",SqlDbType.VarChar).Value= drdpRole.SelectedItem; command.ExecuteNonQuery(); } catch(Exception ex_) { Response.Write("Error occured"+ ex_.Message + ""); } finally { con.Close(); } } }
command.Parameters.Add("@Role",SqlDbType.VarChar).Value= drdpRole.SelectedItem;
ListItem
String
command.Parameters.Add("@Role",SqlDbType.VarChar).Value= drdpRole.SelectedItem.Text;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)