T
Tomer
Hi,
I've created a table in run time that has a primary key composed of two
fields.
The table creation sql is this:
"Create table CertDetail (AIndex int, Barcode nvarchar(20), Primary Key
(AIndex,Barcode))"
I'm using a SqlCeCommandBuilder to create the DataAdapter sql commands
(insert, delete, update)
CertHeadAdapter = new SqlCeDataAdapter("Select * from CertHead",Conn);
CmdBuilder = new SqlCeCommandBuilder(CertDetailAdapter);
CertDetailAdapter.InsertCommand = CmdBuilder.GetInsertCommand();
CertDetailAdapter.UpdateCommand = CmdBuilder.GetUpdateCommand();
CertDetailAdapter.DeleteCommand = CmdBuilder.GetDeleteCommand();
CmdBuilder.Dispose();
Then I use a DataAdapter to fill a DataSet with the table's Schema and it's
Data.
CertDetailAdapter.FillSchema(ds,SchemaType.Source,"CertDetail"); // needed
for find function
TblCertDetail = ds.Tables["CertDetail"];
When I'm looking at the DataAdapter's Delete Command, I see that its delete
according to only one key (the first) with the other.
The Sql command goes like this:
Delete from CertDetail where AIndex=?
where it should be:
Delete from CertDetail where AIndex=? and Barcode=?
This Issue is causing me problems when I try to delete a row from the
DataTable. What happens is that the delete operation deletes all the rows
that have the AIndex value of the row I'm trying to delete.
Whats going on here? Am I doing something wrong or Am I using it the wrong
way?
Tomer.
I've created a table in run time that has a primary key composed of two
fields.
The table creation sql is this:
"Create table CertDetail (AIndex int, Barcode nvarchar(20), Primary Key
(AIndex,Barcode))"
I'm using a SqlCeCommandBuilder to create the DataAdapter sql commands
(insert, delete, update)
CertHeadAdapter = new SqlCeDataAdapter("Select * from CertHead",Conn);
CmdBuilder = new SqlCeCommandBuilder(CertDetailAdapter);
CertDetailAdapter.InsertCommand = CmdBuilder.GetInsertCommand();
CertDetailAdapter.UpdateCommand = CmdBuilder.GetUpdateCommand();
CertDetailAdapter.DeleteCommand = CmdBuilder.GetDeleteCommand();
CmdBuilder.Dispose();
Then I use a DataAdapter to fill a DataSet with the table's Schema and it's
Data.
CertDetailAdapter.FillSchema(ds,SchemaType.Source,"CertDetail"); // needed
for find function
TblCertDetail = ds.Tables["CertDetail"];
When I'm looking at the DataAdapter's Delete Command, I see that its delete
according to only one key (the first) with the other.
The Sql command goes like this:
Delete from CertDetail where AIndex=?
where it should be:
Delete from CertDetail where AIndex=? and Barcode=?
This Issue is causing me problems when I try to delete a row from the
DataTable. What happens is that the delete operation deletes all the rows
that have the AIndex value of the row I'm trying to delete.
Whats going on here? Am I doing something wrong or Am I using it the wrong
way?
Tomer.