M
mark6139
I have created a strongly typed dataset in C# using "Generate DataSet"
from the schema viewer/designer in Visual Studio .Net 2003. And I'm
using this in a Windows Forms application.
The database is an Access file.
I have created the associated data adapter and added an insert command
using the command builder wizard.
The resulting code for the insert command looks like this:
//---------------
this.simsInsertCommand.CommandText = "INSERT INTO Sims(simNum,
simTitle) VALUES (?, ?)";
this.simsInsertCommand.Connection = this.conContent;
this.simsInsertCommand.Parameters.Add(new
System.Data.OleDb.OleDbParameter( "simNum",
System.Data.OleDb.OleDbType.Integer, 0, "simNum"));
this.simsInsertCommand.Parameters.Add(
new System.Data.OleDb.OleDbParameter("simTitle",
System.Data.OleDb.OleDbType.VarWChar, 50, "simTitle"));
this.dtaSims.InsertCommand = this.simsInsertCommand;
//----------------
And my code for testing purposes to create a new row and update it in
the database:
//--------------------
dtsSims.SimsRow sr =
(dtsSims.SimsRow)dataSetInstance.Sims.NewSimsRow();
sr.BeginEdit();
sr.simNum = 33;//this is an auto number column and it also doesn't
work if
//I leave this out
sr.simTitle = "Test case";
sr.EndEdit();
dtaSims.Update(dataSetInstance.Sims);
//-------------------------------------
I get no error but also see no change to the database.
Could someone please tell me what I am missing?
Thanks for any suggestions,
Mark
from the schema viewer/designer in Visual Studio .Net 2003. And I'm
using this in a Windows Forms application.
The database is an Access file.
I have created the associated data adapter and added an insert command
using the command builder wizard.
The resulting code for the insert command looks like this:
//---------------
this.simsInsertCommand.CommandText = "INSERT INTO Sims(simNum,
simTitle) VALUES (?, ?)";
this.simsInsertCommand.Connection = this.conContent;
this.simsInsertCommand.Parameters.Add(new
System.Data.OleDb.OleDbParameter( "simNum",
System.Data.OleDb.OleDbType.Integer, 0, "simNum"));
this.simsInsertCommand.Parameters.Add(
new System.Data.OleDb.OleDbParameter("simTitle",
System.Data.OleDb.OleDbType.VarWChar, 50, "simTitle"));
this.dtaSims.InsertCommand = this.simsInsertCommand;
//----------------
And my code for testing purposes to create a new row and update it in
the database:
//--------------------
dtsSims.SimsRow sr =
(dtsSims.SimsRow)dataSetInstance.Sims.NewSimsRow();
sr.BeginEdit();
sr.simNum = 33;//this is an auto number column and it also doesn't
work if
//I leave this out
sr.simTitle = "Test case";
sr.EndEdit();
dtaSims.Update(dataSetInstance.Sims);
//-------------------------------------
I get no error but also see no change to the database.
Could someone please tell me what I am missing?
Thanks for any suggestions,
Mark