0

I have a Winforms application that uses a SQL Server database. I have a documents table and a files table.

The application gets the information of a file and saves it as a row in the documents table and then it opens a browser to save the file. The file path is then saved in the files table which is linked to the documents table.

Now what I want to do is that if the person didn't choose a file or for whatever reason their file is not qualified, it not only shows a message but it also deletes the row for which no file is chosen/saved.

I checked a couple of answers about "deleting a row in a SQL Server table from a Winforms application (like this Data Table + delete a row in c# using loop)" but it is not quite what I need.

Can anyone help?

Community
  • 1
  • 1
Zoe
  • 35
  • 5
  • what you have tried yet? – Sandip - Frontend Developer Sep 18 '16 at 11:06
  • anything I try seems to be wrong. – Zoe Sep 18 '16 at 11:36
  • 2
    if the file is not qualified, don't save the record in the first place – rlee Sep 18 '16 at 14:33
  • it is like this: the user needs to fill in the info. Then they click SAVE, then the explorer window opens for them to choose the file. Now imagine that someone just "cancels" this new window. I want to delete the record as well if they do. So that they HAVE to have a file – Zoe Sep 18 '16 at 14:35
  • 1
    Why not only save the record in the database if the user clicked on OK in stead of cancel – GuidoG Sep 19 '16 at 07:21
  • They happen sequentially. First, the record is saved in "documents" table and then the browser opens. So, by the time the person decides whether to choose a file or not, the record is already saved. – Zoe Sep 19 '16 at 11:39

0 Answers0