I am developing one web app in which i need to connect to 6 access databases one at a time.
The problem is that the code does not work well properly, sometimes it gets stuck over
Executereader() function and when i use the debugger to know the value of Connection , Command
it 's shown as
Error: can not obtain value.(there is one sign of refresh button)
The same sign is for all the members of the connection object and all the onjects invloved like command and reader !
The problem is that the code jams sometims in the 1st database sometimes in the second etc etc.
How to get around this problem ?
Please help it's very urgent !
13 1689
First thing I would probably do is review the code to make absolutely sure that you're closing all connections when finished with them.
I've seen similar things happen myself when connections aren't closed properly, so I'd eliminate that first and take it from there.
Thanks bro.
Here is the code - While (isfound = False)
-
Try
-
con = New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;Persist Security Info=False; data source=" & Server.MapPath("App_data/PAT_ATT" & dbiterator.ToString() & ".mdb"))
-
con.Open()
-
If mode = "appno" Then
-
cmd = New OleDbCommand("Select * from temp where appno = '" & appnumber & "'", con)
-
Else
-
cmd = New OleDbCommand("Select * from temp where cnm = '" & appname & "'" & " and dob='" & appdob & "'", con)
-
End If
-
reader = cmd.ExecuteReader()
-
If reader.HasRows Then
-
isfound = True
-
Session("patravi2008searchedappno") = reader("appno").ToString()
-
Session("patravi2008founddatabase") = dbiterator
-
LabelRoll.Text = reader("rol").ToString
-
LabelName.Text = reader("cnm").ToString
-
LabelFName.Text = reader("fnm").ToString
-
LabelappNo.Text = reader("AppNo").ToString
-
LabelCat.Text = reader("cat").ToString
-
LabelDOB.Text = reader("dob").ToString
-
Labelsex.Text = reader("sex").ToString
-
LabelClass.Text = reader("class").ToString
-
Labelcentre.Text = reader("cnt_cd").ToString & " --" & reader("cnt_nm").ToString
-
LabelCN.Text = reader("vypno").ToString
-
studentimage.ImageUrl = "patravi2008showpic.aspx?"
-
sign.ImageUrl = "patravi2008showsign.aspx?"
-
End If
-
-
Catch ex As Exception
-
-
Finally
-
If con.State = ConnectionState.Open Then
-
con.Close()
-
con = Nothing
-
End If
-
-
If reader.IsClosed = False Then
-
reader.Close()
-
End If
-
dbiterator = dbiterator + 1
-
End Try
-
I dont think there is some problem in the code.
One imp thing is that i can see some thread.ThreadabortException in mscorlib.dll in the output window.
Is there any relation with that ?
PS:It's very urgent.
I can also see some "code has exited with code 0" three times in the output window.
Try changing the order of releasing in the finally block as shown below, also, include the null check before you access the object... - Finally
-
If reader <> Nothing and reader.IsClosed = False Then
-
reader.Close()
-
End If
-
-
If con <> Nothing con.State = ConnectionState.Open Then
-
con.Close()
-
con = Nothing
-
End If
-
-
dbiterator = dbiterator + 1
-
End Try
-
@Ramk
hi akshay,
did your problem is solved?
I came to know that that it was happening coz of the slow OleDbConnection and OleDbCommand.
As far as "Value not shown" error, it was coz of the fact that the fuction was getting executed somewhere else (System.Data.dll) so the debugger is unable to obtain the data for al the objects involved (Connection,Comand and reader)
After reviewing the code you've posted I don't see where you are connecting to 6 Access databases at the same time.
You will see a thread.ThreadabortException when you redirect to a new page...this aborts the current thread before it's finished executing. If you specify the URL and a Boolean as parameters for the Redirect() method you can avoid these errors.
Are you seeing the ADO errors in your Catch block?
-Frinny
Well I see that you are only trying to close the connection if the state is "open"
What if it is in one of the other states? Then it gets left open, and the jet DB driver will be angry
@Frinavale
See the while loop.
Also i am not connecting to 6 access databases at the same time, it's one by one i am iterating over them.
@Plater
yes a good point.Now i guess the code should be
if(con.State <> ConnectionState.Close)
Con.Close()
?
@akshaycjoshi
It probably wouldn't hurt. Can't be sure if it will solve problem or not
@Plater
Can a broken connection be closed ?
I have hunch.
I guess if you really wanted to, you could switch on the connectionstate and look to see if it ever comes back in an odd state.
I have not run into a problem closing a broken connection before, that I am aware of.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Levent |
last post by:
Folks,
I am getting following message from pear. I am running RedHat 8.0,
PostgreSQL is 7.3.2 PHP Version 4.2.2 and pear:db 1.6.5.
Warning: pg_errormessage(): supplied argument is not a valid...
|
by: Park997 |
last post by:
Hi,
I have a script that runs correctly in IDLE, runs correctly when invoked in the
Command Prompt (Win XP), runs correctly from Komodo, but flashes a black box
too fast to see when the icon is...
|
by: sachin bond |
last post by:
The following code(in c++) is supposed to divide a file into 'n' different
files.
suppose i'm having a file called "input.zip".
The execution of the following code should divide "input.zip"...
|
by: Deano |
last post by:
My form is set up so that if I add a record to my main form, a related
record is created in the subform. This occurs in the afterupdate event of
my main control.
I have made a few changes here,...
|
by: Gorgen |
last post by:
I have a namespace LogRead with one class in it: LogReadWindow
I want to program doing a protoype so I write LogRead.ReadLog() on an
apropiate place. But it is always changed to...
|
by: Bruno van Dooren |
last post by:
Hi all,
i am working a some C++ software that will run both on windows and linux.
development is done on windows with VS .NET 2003.
when i view and edit source files on linux (using Vim), all...
|
by: PJ6 |
last post by:
I have no idea why, but when I place breakpoints when running one of my
applications in debug mode, they never appear where I want them to,
sometimes they even pop up in a different method than the...
|
by: Axel Dahmen |
last post by:
Hi,
when I'm opening the ASP.NET 2.0 Website Configuration Manager in IIS I get quite confused about the values it displays at the Application tab.
For example, it states I'd be using af-ZA as...
|
by: rn5a |
last post by:
During registration, users are supposed to enter the following
details: First Name, Last Name, EMail, UserName, Password, Confirm
Password, Address, City, State, Country, Zip & Phone Number. I am...
|
by: Ali Rizwan |
last post by:
Hi
I have problem from a couple of years it is the runouce problem how can i solve it it cannot be deleted from taskmanager and not from regestiry can some body help me?
Thanx
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |