Reputation: 100
I am having some troubles figuring out why I receive a NullReferenceException
when using this code:
entityCustomer customer = new entityCustomer {
firstName = txtFName.Text,
lastName = txtLName.Text,
homeAddress = txtAddress.Text,
phoneNumb = txtPhone.Text,
emailAddress = txtEmail.Text
};
custTable.InsertOnSubmit(customer);
dc.SubmitChanges();
I get the error on InsertOnSubmit
. Here is my entity class:
I tried following https://stackoverflow.com/a/788402/2416047, as you can see, but still had no luck.
What am I doing wrong?
Upvotes: 0
Views: 742
Reputation: 2583
Your custTable
variable, parameter, property or field is null.
You need to assign a value to it before calling any of its members.
Upvotes: 2