Run query to effect dataset only

  • Thread starter Thread starter Vayse
  • Start date Start date
V

Vayse

Hi
If I add a query to a table adapter, it updates the database. For example
Me.ScheduleTableAdapter.DeleteByAsset(Me.txtAssetCode.Text)
will delete all schedules for the asset. Is there something similiar that
would effect just the dataset? That is, not update the database until I ran
my save routines?

Thanks
Vayse
 
Hi Vayse,

Because the DeteteBy command will run a TSQL DELETE command in the SQL
directly, I think we need to use another approach.

I think you may try to call FindBy on the Table and call delete method on
the returned datarow.
DataRow.Delete Method
Remarks
If the RowState of the row is Added, the row will be removed from the table.

The RowState becomes Deleted after using the Delete method. It remains
Deleted until you call AcceptChanges.

A deleted row can be undeleted by invoking RejectChanges.

As MSDN said, if you did not call AcceptChanges, the change will not be
applied into database.



Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Ok, I think I get it. Theres no query way as such, I have to change each row
individually, then run Accept or Reject changes.
 
Hi

If you still have any concern, please feel free to post here.
Also I just wonder you want to cache the delete rows. If you just did not
want to see it, I think you may just use the filter of the dataview to
display the rows you wants. You can do deleteby only when you really do not
want the data again.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top