Click here to Skip to main content
15,904,023 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

This is a very difficult problem and I have no idea whats the problem so I will appreciate any help.

****I will try to detail the problem as much as possible so please don't hate me for the long article but when you read it you will be as baffled as I am because I have programmed databases before many times but this is the first time this has ever happened to me.

_____________________________________________________________________________________________
I have an application with two forms (form1, form2). form1 has a lot of labels one of them has click event that lunches form2 after defining a variable of form2 and call .show().form2 connects to an access database using a class library (.dll) that I have also created (this dll handles all the operations and object creation necessary to connects to the database. Every time form2 loads all the objects are recreated from scratch and I make sure first that the objects are null so everything and every variable is at the initial value. in form2 there are calls to INSERT,UPDATE,DELETE performed on the database all of them are performed successfully and I call them multiple times using buttons. At this point Everything is working perfectly as you may assume the problem is when I press the buttons to INSERT or\and DELETE records from the database and I close form2 then on form1 I open form2 again everything works perfectly but if I call UPDATE for one time or multiple times in form2 it also works perfectly and the data in the database are changed correctly but after I close form2 and open it again the application crashes and windows pops up the program crash window that requires you to close the program.

After 2 days of testing and debugging during which I changed the way I connect to the database and a lot of things, I also changed the SQL UPDATE string to an SQL INSERT string just in case the problem is in the update button some how and it worked but when I change it back to an SQL UPDATE string it crashes just like i mentioned above.

I back-traced the problem and found that after I perform UPDATEs when I start form2 again the oledbconnection object is recreated successfully and oledbconnection.open() is called successfully but when I close the connection (oledbconnection.close()) that is when every thing goes to hell.

Can any one help? I am desperate.


NOTE:-

the program doesn't throw an exception, instead windows displays the ( [program_name] has stopped working ) window with three options:
1)Check online for a solution and close the program
2)Close the program
3)Debug the program
just like when a program that is installed on the computer crashes.
Posted
Updated 24-Oct-13 6:11am
v2
Comments
Pradeep Shukla 23-Oct-13 22:35pm    
What exactly happens that you call as "every thing goes to hell".. please post the exception detail.. that may help to identify and isolate the issue.
Hussain Marzah 24-Oct-13 12:09pm    
the program doesn't throw an exception, I wish it did.
windows displays the ( [program_name] has stopped working ) window with three options:
1)Check online for a solution and close the program
2)Close the program
3)Debug the program
bowlturner 24-Oct-13 12:45pm    
Are you leaving transaction without a rollback or commit? It might be trying to close the connection but is in a deadlock state?
Hussain Marzah 24-Oct-13 13:42pm    
if I am how do I solve this deadlock state?
Hussain Marzah 24-Oct-13 14:14pm    
I am not using a transaction, simply an OledbConnection with OledbCommand objects, and when I view the connection state before closing form2 it is closed.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900