New records are not persistent in SQL Server Db

Ralph1965

New member
Joined
Aug 15, 2009
Messages
1
Programming Experience
1-3
Hello,

I'm trying to learn how to write and save a new record to a SQL Server Db using LINQ.

When I run my code and view the data in the table, the new record isn't there. However, when I query the table, the new record shows up! When I close the project, open it up, and run the query the added record is gone.

When I added the Db, I told Visual Studio to save it in the project.

I'm using the Northwind sample Db.

Here's the code:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim NewData As New Customer

NewData.Address = "98224 Ocean Rd"
NewData.City = "Cincinnati"
NewData.CompanyName = "Supplies For Feathers"
NewData.ContactName = "Ralph Owens"
NewData.PostalCode = "45058"
NewData.ContactTitle = "Owner"
NewData.Country = "USA"
NewData.CustomerID = "RKO65"
NewData.Fax = "513-555-5555"
NorthwindSampleDataContext1.Customers.InsertOnSubmit(NewData)
NorthwindSampleDataContext1.SubmitChanges()
NorthwindSampleDataContext1.Connection.Close()


Why doesn't this save my new record?

Thanks,

Ralph
 
Top Bottom