Silverlight / WPF - Delete Command - Asked By David on 31-Dec-10 05:41 AM

Hi

I am trying to use a delete command from Dataset to delete 1 row at a time and the main part of the row is COURSEName.
The code below from configured DataSet does not delete any rows at all.


DELETE FROM COURSE
WHERE   (Prikey3 = ?) AND (? = 1 AND [Date Played] IS NULL OR
            [Date Played] = ?) AND (? = 1 AND COURSEName IS NULL OR
            COURSEName = ?) AND (? = 1 AND H1PAR IS NULL OR
            H1PAR = ?) AND (? = 1 AND H2PAR IS NULL OR

If I change it to the  show the code below it deletes all records

DELETE FROM COURSE

Please help I have been stuck on this for months

David
anil soni replied to David on 31-Dec-10 05:54 AM
You can delete a single record at time using follwing quries

SET ROWCOUNT 1
DELETE FROM COURSE
David replied to anil soni on 31-Dec-10 11:41 AM
Hi Anil

Thanks for the quick reply
I have tried but it did not work it kept saying

Error in table name or view name in DELETE clause.
Unable to parse query text.


Thanks

David
anil soni replied to David on 31-Dec-10 01:17 PM
strange!!!
try using
SET ROWCOUNT 1
DELETE FROM [COURSE]
David replied to anil soni on 31-Dec-10 02:15 PM
Hi Anil
It has not worked.

Do I need to put any filter in query builder?
And do I need to have all the table in the columns

This is the error I now get
Error in table name or view name in DELETE clause.
Unable to parse query text.

Thanks

David
anil soni replied to David on 31-Dec-10 02:20 PM
which database server you are using in your application?
David replied to anil soni on 31-Dec-10 02:24 PM
Hi Anil

I am using a Access Data-base on my Server explorer and then Datasets & Tableadapters.
The Delete command is from the Dataset-tableadapter
This is all in Visual Studio 2008 Xaml etc

Thanks

David
anil soni replied to David on 31-Dec-10 03:42 PM
ohhh i thought you are sql server and gave you solution for that anyways you can delete a particular record if you have primary key in your table else you have to give condition whcih  matches only a single record in order to delete single record.
David replied to anil soni on 01-Jan-11 04:46 PM

Hi Anil

I have a primary key called Prikey3


DELETE FROM COURSE
WHERE   (Prikey3 = ?) AND (? = 1 AND [Date Played] IS NULL OR
      [Date Played] = ?) AND (? = 1 AND COURSEName IS NULL OR
      COURSEName = ?) AND (? = 1 AND H1PAR IS NULL OR
      H1PAR = ?) AND (? = 1 AND H2PAR IS NULL OR

Please how do I change the Criteria to make it work

DELETE FROM COURSE
WHERE   (Prikey3 = ?)   This does not delete any


DELETE FROM COURSE   This deletes all rows


I am using Dataset-Tableadapter-query builder in Visual Studio 2008


Thanks

David