C
Chris Mayers
Hi,
Hope someone can explain this...
OK, here is the simplest subset of my code that shows the problem:
I have a C# Method:
Private void UpdateDataTable(DataTable myDT)
{
OleDbCommand comm = new OleDbCommand();
comm.CommandText = "AddComponentsForJobT";
comm.CommandType = CommandType.StoredProcedure;
OleDbConnection conn = new OleDbConnection(CONNECTION_STRING);
conn.Open();
comm.Connection = conn;
comm.Parameters.Add("pPartNo",OleDbType.VarChar,10,"PartNo").SourceVersion
= DataRowVersion.Current;
da.InsertCommand = comm;
da.Update(myDT);
}
An Access Query:
AddComponentsForJobT
==================
PARAMETERS pPartNo Text ( 255 );
INSERT INTO PropJobParts ( PartNo )
SELECT [pPartNo] AS Expr2;
If I pass into the above method a DataTable containing 3 rows with a
RowState of 'Added'
PartNo
=====
AAA
BB
C
The code runs successfully, but what finished up in my Access table is:
AAA
BBA
CBA
Anyone tell me what I'm doing wrong or missing out??? It seems like the
Automagic stuff inside OledbDataAdapter.Update that runs the Insert command
is not clearing the parameters between each subsequent insert.
Please!
Thanks,
Chris.
Hope someone can explain this...
OK, here is the simplest subset of my code that shows the problem:
I have a C# Method:
Private void UpdateDataTable(DataTable myDT)
{
OleDbCommand comm = new OleDbCommand();
comm.CommandText = "AddComponentsForJobT";
comm.CommandType = CommandType.StoredProcedure;
OleDbConnection conn = new OleDbConnection(CONNECTION_STRING);
conn.Open();
comm.Connection = conn;
comm.Parameters.Add("pPartNo",OleDbType.VarChar,10,"PartNo").SourceVersion
= DataRowVersion.Current;
da.InsertCommand = comm;
da.Update(myDT);
}
An Access Query:
AddComponentsForJobT
==================
PARAMETERS pPartNo Text ( 255 );
INSERT INTO PropJobParts ( PartNo )
SELECT [pPartNo] AS Expr2;
If I pass into the above method a DataTable containing 3 rows with a
RowState of 'Added'
PartNo
=====
AAA
BB
C
The code runs successfully, but what finished up in my Access table is:
AAA
BBA
CBA
Anyone tell me what I'm doing wrong or missing out??? It seems like the
Automagic stuff inside OledbDataAdapter.Update that runs the Insert command
is not clearing the parameters between each subsequent insert.
Please!
Thanks,
Chris.