Crash during inserter into SQLCE DB
Is anyone else having trouble with their app crashing with a native error when their app tries to insert into a SQLCE database shortly after turning on the device?
Just in case I didn't explain the problem well in my first attempt.
My app gathers data entered by the user and stores it in local variables. The device is frequently turned off and on during the data gathering process.
Once all data is collected, the program then passes the data to an object that inserts into the database.
It's at this point that the app crashes, no exceptions are thrown from my try blocks, but once in a while I'll get some kind of native error.
Re: Crash during inserter into SQLCE DB
No, I can say that I have never seen that. Sounds like it will be fairly tough to diagnose, too. Are you debugging on hardware, or an emulator? Can you get this to happen while debugging?
Re: Crash during inserter into SQLCE DB
It happens on the actual hardware.
I can't get it to crash right after the program starts running, it only does it after the device is turned off and then turned back on while the program is still running, so I don't think the debugger will keep running if I turn off the device. I'm storing the database on the storage card, would that be a problem? I'm not at work today, so I'll try moving it to memory on friday.
I've got another pocket pc, but I have to order a charger for it, guess this is the right motivation to finally get that done :D .
As a temp solution, I'm going to dump the data into a text file and then write another quick program that will take the data and stick it in the database.
This is very frustrating, it doesn't seem to have a problem reading from the database right after it's turned on, it only crashes on INSERT lines.
Just to experiment a bit more, I wrote a small program that just inserts the time and date as a string into a test table in the same database when a button is pressed. I get the same problem, instant crash. I then created a whole new database and tried the same test program, still crashes. All of these databases were on the storage card. It wasn't until I started typing this that I thought about moving the database to memory.
Re: Crash during inserter into SQLCE DB
Have you tried re-install SQLCE?
Re: Crash during inserter into SQLCE DB
I always keep dbs on the storage card, so that shouldn't be your issue.
What happens when it crashes? You stated that no error messages came from your try blocks. I would assume that you wrapped the INSERT statement in a Try block, but you might as well confirm, just for grins.
The next things I would try would be these:
1) Prior to the INSERT statement, I would look at the connection object, to see that there are no obvious issues.
2) Immediately prior to the INSERT statement, I would try a SELECT statement to see whether I can do ANYTHING with the DB, or if it is just the INSERT that fails at that precise moment.
Re: Crash during inserter into SQLCE DB
Quote:
Originally Posted by sapator
Have you tried re-install SQLCE?
yep, several times. I've also done a few factory resets and fully reinstalled .net compact.
Shaggy, I did confirm that the try block encases the insert command.
I'll try executing a select command before the insert command next chance I get. I didn't get any time to work on it today.
Thanks guys, I always appreciate having a couple extra minds to help me come up with things to try.
Re: Crash during inserter into SQLCE DB
Well, it looks like I've found a temp solution. I think I'm dealing with a hardware problem rather then a programming problem. If I put a 45 second pause in the sub routine that does the Insert before it tries to open the database connection, the problem does not occur. I'll have to wait until the new charger gets here for my other device to confirm this, but I expect that the other device will work just fine without the pause.
Re: Crash during inserter into SQLCE DB
So the connection is not opening in time for the INSERT command to be performed?
Are you serious with the 45 second pause? That's insane.
Re: Crash during inserter into SQLCE DB
See this thread
http://www.vbforums.com/showthread.p...hlight=sd+card
We encountered SD CARD issues when the PPC's are initially turned on ourselves.
Re: Crash during inserter into SQLCE DB
Quote:
Originally Posted by Shaggy Hiker
So the connection is not opening in time for the INSERT command to be performed?
Are you serious with the 45 second pause? That's insane.
I tried 5 and then 20, neither one worked, I kicked it up to 45 seconds to try an extreme delay and it worked 10/10 tries so I just left it there.
Quote:
Originally Posted by szlamany
My issue may be related to yours. Even though I moved the database to the main memory, I still have .net installed on the card. Adding the 45 second delay may be giving the device enough time to mount the card.
I wonder what the power on routine looks like on these devices. Maybe on mine, the instruction to find and mount the SD card is way at the bottom. Maybe on others, the device just never loses contact with the card.
Either way, the 45 second delay isn't that big of a problem for this program, the user has things to do after completing the data collection. I'll toss on a progress bar and a flashing "WRITING TO DATABASE - DO NOT INTERRUPT" message and call it good :D .
Re: Crash during inserter into SQLCE DB
People are too impatient to wait for 2 seconds, and you will have them wait for most of a minute?
Still, I have no solution or suggestion at this point. I've never seen it happen before, and hope I never do.
Ok, here's a way out suggestion that may not even be possible: When you start up, since you can read from the DB, fill a detached dataset, and use that as your (temporary) memory resident database. In theory, you should then be able to update the database from the dataset after the alloted time has expired.
Re: Crash during inserter into SQLCE DB
I agree that 45 seconds is an age to wait - progress bar or not.
Why install .Net on the card - what happens if you install in main memory.
When you say 'it just crashes', do you get any messages at all or does the application just end?
What happens if you do a if system.io.file.exists(fname) on a file on the storage card after you turn back on - if it finds it, then the storage card is mounted
Pete
Re: Crash during inserter into SQLCE DB
A mounting issue doesn't fit the symptoms anyways, because you said in the first post that you can read from the DB just fine, only INSERTS fail.
Re: Crash during inserter into SQLCE DB
If I get a chance today, I'll put some text logging into the object that crashes. I want to see if it crashes on the same line every time. I'll also do a factory reset and let it install .net and everything to main memory.