Despair

Over the past two months I have fixed what should have been two simple problems.

1. When a subpreport was added to a report it would crash when run from the program calling. No matter what was done or changed it would crash but it would run fine in the report designer. The sad fact is that the new subreport was correct but left out of the project. So every time the project was rebuilt it never got copied. Why did this happen? The subreport had a similar name as one that was already included in the project and it got overlooked.

Lesson learned: Always take a look at the simpler things (is the file included) before looking for more serious problems.

2. A new DataAdapters select command and update command worked. However when the insert command was run there would be no errors returned, no error events. Nothing at all. It would run as if it had worked but when I checked the database the new rows would not be there. I checked everything. I checked every parameter. I checked the sql insert string. I checked the connection. I checked command type, the DataAdapter type, the connection type. I checked the DataSet schema. I checked the dataset tables. I checked the table rows. I checked the dataadapter update call. I checked that the DataAdapter insert command was set correct. None of it worked.

Next I turned to reviewing ADO.NET. I read on msdn all about dataadapters, parameters, command, and all the related materials and articles. I google searched for the problem and there was nothing there to help.

So I tried using a DBcommandBuilder to create the insert and it worked immediately. I compared the command builders insert command against mine. They were completely the same. WTF was going on. Why is my insert command not working. As with the subreport problem it was very simple problem indeed. My insert command was correct.

The problem that I noticed with the debugger was that the damn insert command text was set to the update command text. But how could this be. I checked the source code and it was set to the insert string. What I found a few lines down further of course should be no surprise. I was accidentally assigning the update sql to the insert command text.

Lesson Learned: Don't be a dumbass.

pron