InsertOnSubmit gives this error. How do I fix this?

135 views Asked by At

InsertOnSubmit gives error "there is no argument given that corresponds to the required formal parameter 'entity' of table.InsertOnSubmit(chalet)". How do I fix this?

This is my code.

public partial class MainWindow : Window
{
    DataClasses1DataContext db = new DataClasses1DataContext();
    public MainWindow()
    {
        InitializeComponent();
    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        chalet hetHuis = new chalet();

        hetHuis.Naamcode = naamcode.Text;
        hetHuis.Persoonaantal = Convert.ToInt32(personenaantal.Text);
        hetHuis.Klasse = Convert.ToString(klasse.SelectedItem);

        db.chalets.InsertOnSubmit();
        db.SubmitChanges();
    }
}

it gives the error at db.chalets.InsertOnSubmit();

1

There are 1 answers

0
Sumit raj On BEST ANSWER

Pass the entity in db.chalets.InsertOnSubmit(); like db.chalets.InsertOnSubmit(hetHuis);