-1

InsertOnSubmit 给出错误“没有给出与 table.InsertOnSubmit(chalet) 所需的形式参数'entity'相对应的参数”。我该如何解决?

这是我的代码。

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();
    }
}

它在 db.chalets.InsertOnSubmit() 处给出错误;

4

1 回答 1

0

db.chalets.InsertOnSubmit();像这样传递实体db.chalets.InsertOnSubmit(hetHuis);

于 2018-05-25T20:04:21.230 回答