The SubmitChanges method determines the changed data such as newly added data, as in this case, or
modifications to existing data, and then executes the correct commands to create and usher the changes
back to the database.
The InsertNames routine allows new contacts to be created simply and efficiently.
You are now ready to start adding modification code. Open Form1 in design mode and add three buttons
and a text box. Behind button1, add the following highlighted code (you can use other names and
email addresses):
private void button1_Click(object sender, EventArgs e)
{
this.InsertNames("Scott", "Mr.", "ScottKlein@SqlXml.com");
this.InsertNames("Chris", "Mr.", "Chris@SomeCompany.com");
this.InsertNames("Jason", "Mr.", "Jason@SomeCompany.com");
this.InsertNames("Richard", "Mr.", "Dad@Home.com");
this.InsertNames("Courtney", "Mrs.", "Sis@SomeCompany.com");
this.InsertNames("Carolyn", "Mrs.", "Mom@Home.com");
textBox1.Text = "Contact added successfully";
}
Run the Visual Studio project you created by pressing F5, and when the form displays, click button1.
Pages:
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420