Hey,
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=AG_FAT;Integrated Security=True");
con.Open();
SqlCommand cmd = new SqlCommand("insert into Fatura(Kimlik,No,Date,Total,Type,D1,T1,D2,T2,D3,T3,Rest,Info) values(@Kimlik,@No,@Date,@Total,@Type,@D1,@T1,@D2,@T2,@D3,@T3,@Rest,@Info)", con);
cmd.Parameters.AddWithValue("@Kimlik", textBox1.Text);
cmd.Parameters.AddWithValue("@No", textBox2.Text);
cmd.Parameters.AddWithValue("@Date", textBox3.Text);
decimal total = decimal.Parse(textBox5.Text);
cmd.Parameters.AddWithValue("@Total", total);
cmd.Parameters.AddWithValue("@Type", textBox6.Text);
cmd.Parameters.AddWithValue("@D1", textBox7.Text);
decimal t1 = decimal.Parse(textBox10.Text);
cmd.Parameters.AddWithValue("@T1", t1);
cmd.Parameters.AddWithValue("@D2", textBox8.Text);
decimal t2 = decimal.Parse(textBox11.Text);
cmd.Parameters.AddWithValue("@T2", t2);
cmd.Parameters.AddWithValue("@D3", textBox9.Text);
decimal t3 = decimal.Parse(textBox12.Text);
cmd.Parameters.AddWithValue("@T3", t3);
decimal rest = decimal.Parse(textBox13.Text);
cmd.Parameters.AddWithValue("@Rest", rest);
cmd.Parameters.AddWithValue("@Info", textBox4.Text);
cmd.ExecuteNonQuery();
SqlDataReader dr1;
try
{
dr1 = cmd.ExecuteReader();
while(dr1.Read())
{
comboBox1.Items.Add(dr1[0]);
con.Close();
}
}
catch (Exception es)
{
MessageBox.Show(es.Message, "FAIL");
}
con.Close();
MessageBox.Show("SUCCESS");
I'm just trying to add values to sql by filling textboxes and a combobox. I don't know why but when i click on "Add" Button on my software, nothing adds on my combobox but same 2 row is going to add on SQL Table. I want to add all textbox info to table on SQL and add only "Kimlik" column to combobox.