try
{
SqlConnection con = new SqlConnection("server=YASH-BA85E3332D\\SQLEXPRESS;database=db_dda;trusted_connection=yes;");
SqlCommand cmd = new SqlCommand("insert into houseing_booking( application_n,f_name,l_name,age,dob,address,phone,housing_scheme_name,house_category,advance_draft_amount,issuing_bank,draft_no,dd_date,date_of_application,bank_ac_number)values (@application_n,@f_name,@l_name,@age,@dob,@address,@phone,@housing_scheme_name,@house_category,@advance_draft_amount,@issuing_bank,@draft_no,@dd_date,@date_of_application,@bank_ac_number)", con);
DataSet ds = new DataSet();
SqlDataAdapter adp;
cmd.CommandType = System.Data.CommandType.Text;
cmd.Parameters.Add("@application_n", SqlDbType.Int).Value = int.Parse(TextBox1.Text);
cmd.Parameters.Add("@f_name", SqlDbType.VarChar).Value = TextBox2.Text;
cmd.Parameters.Add("@l_name", SqlDbType.VarChar).Value = TextBox3.Text;
cmd.Parameters.Add("@age", SqlDbType.Int).Value = int.Parse(TextBox4.Text);
cmd.Parameters.Add("@dob", SqlDbType.DateTime).Value = TextBox5.Text;
cmd.Parameters.Add("@address", SqlDbType.VarChar).Value = TextBox6.Text;
cmd.Parameters.Add("@phone", SqlDbType.Int).Value = int.Parse(TextBox7.Text);
cmd.Parameters.Add("@housing_scheme_name", SqlDbType.VarChar).Value = TextBox8.Text;
cmd.Parameters.Add("@house_category", SqlDbType.VarChar).Value = TextBox9.Text;
cmd.Parameters.Add("@advance_draft_amount", SqlDbType.Int).Value = int.Parse(TextBox10.Text);
cmd.Parameters.Add("@issuing_bank", SqlDbType.VarChar).Value = TextBox11.Text;
cmd.Parameters.Add("@draft_no",SqlDbType.Int).Value = int.Parse(TextBox12.Text);
cmd.Parameters.Add("@dd_date", SqlDbType.DateTime).Value = TextBox13.Text;
cmd.Parameters.Add("@date_of_application", SqlDbType.DateTime).Value = TextBox14.Text;
cmd.Parameters.Add("@bank_ac_number", SqlDbType.VarChar).Value = TextBox15.Text;
adp = new SqlDataAdapter(cmd);
adp.Fill(ds, "houseing_booking");
Label19.Text="Congratulation Booking Confirmed!!!!!!";
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox8.Text = "";
TextBox9.Text = "";
TextBox10.Text = "";
TextBox11.Text = "";
TextBox12.Text="";
TextBox13.Text="";
TextBox14.Text="";
TextBox15.Text = "";
}
catch (SqlException se)
{
if (se.ErrorCode == 2627)
{
Label19.Text = " Application No. already exists in database";
}
else
{
Label19.Text="Exception occured !!!! Plz reload and try again later";
}
}
finally
{
}
No comments:
Post a Comment