Good day everyone i am working on a loan application. i am using three usercontrols and one form. the usercontrols are(registrationform,userprofile,loan status). the registrationform usercontrol contains button,textboxs,picturebox and datetimepicker and the userprofile usercontrol consist of a datagridview that shows newly inserted data. please i want the datagridview to automatically update after the user inserts there data.
sometimes it gives me this error
There is no argument given that corresponds to the required formal parameter 'upa' of 'Registrationform.Registrationform(userprofile)'
please i need full correction.
What I have tried:
usercontrol registrationform
public partial class Registrationform : UserControl
{
userprofile up;
public Registrationform(userprofile upa)
{
InitializeComponent();
up = upa;
con.Open();
private void btnreg_Click(object sender, EventArgs e)
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "INSERT INTO Registrationform([Employementnumber],[FullName],[Dateofbirth],[Gender],[Occupation],[Maritalstatus],[Email],[Department],[Position],[HomeAddress],[Phonenumber],[Nationality],[Stateoforigin],[image]) VALUES (@empno,@fullname,@dob,@gen,@occ,@ms,@email,@dept,@post,@haddress,@pno,@nation,@soo,@img)";
cmd.Parameters.AddWithValue("@empno", txtempno.Text);
cmd.Parameters.AddWithValue("@fullname", txtfullname.Text);
cmd.Parameters.AddWithValue("@dob", dob.Value);
cmd.Parameters.AddWithValue("@gen", gender);
cmd.Parameters.AddWithValue("@occ", txtoccupation.Text);
cmd.Parameters.AddWithValue("@ms",
cmd.Parameters.AddWithValue("@email", txtemail.Text);
cmd.Parameters.AddWithValue("@dept", txtdept.Text);
cmd.Parameters.AddWithValue("@post", txtpost.Text);
up.disp();
}
usercontrol userprofile
public void disp()
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from Registrationform";
cmd.ExecuteNonQuery();
DataTable data = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(data);
dtuserpro.DataSource = data;
con.Close();