please tell me where am i wrong

try
            {
                OleDbCommand cmd = new OleDbCommand();
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "insert into purchase(pdate,bill id,ritem,suppname,smobno,qty,rate,amount,payment,balance) Values('" +
                    dateTimePicker1.Text.ToString() + "','" + textBox15.Text.ToString() + "','" + textBox7.Text.ToString() + "','" + textBox12.Text.ToString() + "','" + comboBox2.Text.ToString() + "','" + textBox14.Text.ToString() + "','" + textBox13.Text.ToString() + "','" + textBox11.Text.ToString() + "','" + textBox8.Text.ToString() + "','" + textBox10.Text.ToString() + "')";
                cmd.Connection = conn;
                conn.Open();
                //MessageBox.Show("insert into purchase(pdate,bill id,ritem,suppname,smobno,qty,rate,amount,payment,balance) Values('" +
                  //  dateTimePicker1.Text + "','" + textBox15.Text + "','" + textBox7.Text + "','" + textBox12.Text + "','" + comboBox2.Text + "','" + textBox14.Text + "','" + textBox13.Text + "','" + textBox11.Text + "','" + textBox8.Text + "','" + textBox10.Text + "');");
                cmd.ExecuteNonQuery();
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

Edited 5 Years Ago by Narue: Added code tags

Attachments Untitled.png 21.37 KB

i think this is what you need.... :p

open your own oledb connection then in the button edit the code below.. :v

cmd = new OleDbCommand("insert into Users(firstname,lastname,username,[password],weight,height,age,BMI,gender,illness1)" + "values(" + "'" + textBox6.Text + "'" + "," + "'" + textBox7.Text + "'" + "," + "'" + textBox1.Text + "'" + "," + "'" + textBox2.Text + "'" + "," + "'" + textBox4.Text + "'" + "," + "'" + textBox3.Text + "'" + "," + "'" + textBox5.Text + "'" + "," + "'" + bmires2 + "'" + "," + "'" + "M" + "'" + "," + "'" + "hypertension" + "'" + ")", conn);
            cmd.ExecuteNonQuery();
            MessageBox.Show("record has been added", "records");
This article has been dead for over six months. Start a new discussion instead.