So, this is my first test on inserting a record from code.
As stated in the subject, nothing happens (the server table remains empty), but no exception are thrown or errors are raised ( context.HasErrors is false ).
Here is the code. (Edit May/02) May be important to point that Car is a subclass of Vehicles, all the hierarchy in one table.
What am I doing the wrong way?
TIA
Code: Select all
TestDataContext context = new TestDataContext();
Console.WriteLine( context.Connection.ConnectionString );
if (!context.Connection.ConnectionString.Contains( "Password" ))
context.Connection.ConnectionString += ";Password=xxx";
context.Connection.Open();
context.Transaction = context.Connection.BeginTransaction();
Car c = new Car();
c.Brand = "Dodge";
context.Vehicles.InsertOnSubmit( c );
Console.WriteLine( "Submitting " );
context.SubmitChanges();
context.Transaction.Commit();
Console.WriteLine( "HasErrors = " + context.HasErrors.ToString() );