I have serious problem with dataAdapter.Update(..)
-
Sometimes app throws an exception when I try to update one particular table adapter, exception says that it's inner sql adapter is null! That part of code is old at least three years and it work fine until last few days, to make it even stranger when I run through the with debugger it works fine, but when I or testers run it as .exe it crashes again. Same code is used on several places (same data layer) and it crashes only for one controller during insertion. Controller which calls that part of code has two options for saving data, Save and Save and close. Save and close runs into problems, but Save never! Difference is only in form closing. I haven't copied any code because it is simple
someAdapter.Update(myRowCollection);
. Please help. -
Sometimes app throws an exception when I try to update one particular table adapter, exception says that it's inner sql adapter is null! That part of code is old at least three years and it work fine until last few days, to make it even stranger when I run through the with debugger it works fine, but when I or testers run it as .exe it crashes again. Same code is used on several places (same data layer) and it crashes only for one controller during insertion. Controller which calls that part of code has two options for saving data, Save and Save and close. Save and close runs into problems, but Save never! Difference is only in form closing. I haven't copied any code because it is simple
someAdapter.Update(myRowCollection);
. Please help. -
Sometimes app throws an exception when I try to update one particular table adapter, exception says that it's inner sql adapter is null! That part of code is old at least three years and it work fine until last few days, to make it even stranger when I run through the with debugger it works fine, but when I or testers run it as .exe it crashes again. Same code is used on several places (same data layer) and it crashes only for one controller during insertion. Controller which calls that part of code has two options for saving data, Save and Save and close. Save and close runs into problems, but Save never! Difference is only in form closing. I haven't copied any code because it is simple
someAdapter.Update(myRowCollection);
. Please help.What Exception? I had a similar case, in one place in my app I was lazy and used Update and all was fine until I started getting reports of a Concurrency Exception. It turned out that the guy who was generating the data I was working on created some duplicate records; he wasn't supposed to, he said he didn't, and my code couldn't handle it when he did. I changed my code so it doesn't use Update and all is fine. All in all -- don't use DataAdapters!
-
What Exception? I had a similar case, in one place in my app I was lazy and used Update and all was fine until I started getting reports of a Concurrency Exception. It turned out that the guy who was generating the data I was working on created some duplicate records; he wasn't supposed to, he said he didn't, and my code couldn't handle it when he did. I changed my code so it doesn't use Update and all is fine. All in all -- don't use DataAdapters!
This is the exception message: "Object reference not set to an instance of an object." It has no inner exception; as I said SqlDataAdapter of TableAdapter component SOMETIMES is null! However it is NEVER null when I run it through debugger, when I remove breakpoints I can expect problems. But everything is initialized and this very code is used for some years without problems.
-
Have you tried to put Try and Catch blocks around your code to see what the exception is?
Almost entire method is within try-catch block. I've explained exception in other reply.