Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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();
Posted
Updated 30-May-19 20:25pm
Comments
Richard Deeming 31-May-19 8:48am    
That code obviously won't compile. You've tried to declare an event handler inside the constructor. You're using variables that don't exist. You've got random words in the middle of the code. You're missing closing braces.

1 solution

Add a default constructor to RegistrationForm that does NOT require a parameter.

Then figure out where you are calling the form without a parameter (if it's not "design time").
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900