public void insertdata() { try {
con.Open();
OleDbCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into customers(customer_name,address,email,mob_no) values('" + tname.Text + "','" + taddress.Text + "','" + temail.Text + "','" + tmobno.Text + "')";
cmd.ExecuteNonQuery();
MessageBox.Show("Registered Successfully");
con.Close();
tname.Text = "";
taddress.Text = "";
temail.Text = "";
tmobno.Text = "";
}
catch (Exception e)
{
MessageBox.Show("Problem in Registering Customer,Please Enter all Fields Correctly" + e);
}
}
''This is is function which i want to call in another Form which is advancePayment on button_click.
As you want to call the same function at multiple places, what you can do is create another class with insertdata() function in it. After that, you can add reference of that class in your respective forms.