Strangest damn error - database at fault?

N

Neo Geshel

I am working with an Access database, and every now and again I get an
error that forces me to shut down and restart the www service. The
timing is random, and can occur when I am editing, entering or viewing
data. I have Googled this error message, but have gotten nowhere.

The error is:


Server Error in '/' Application.
Unspecified error
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Unspecified error

Source Error:

Line 11: Dim strID as String = Request.QueryString("id")
Line 12: Dim myConn as New
OleDbConnection(ConfigurationSettings.AppSettings("strConn"))
Line 13: myConn.Open()
Line 14: Dim myCmd as New OleDbCommand("SELECT Count(Image) FROM tbl"
& strTable & " WHERE [ID] = " & strID, myConn)
Line 15: If myCmd.ExecuteScalar() <> 0 Then


Source File: C:\Inetpub\wwwroot\kabis.com\hofbrauhaus\image.aspx Line: 13

Stack Trace:

[OleDbException (0x80004005): Unspecified error]
System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) +20
System.Data.OleDb.OleDbConnection.InitializeProvider() +57
System.Data.OleDb.OleDbConnection.Open() +203
ASP.image_aspx.Page_Load(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\kabis.com\hofbrauhaus\image.aspx:13
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750


Version Information: Microsoft .NET Framework Version:1.1.4322.2300;
ASP.NET Version:1.1.4322.2300



Any clues?? I am mystified.

TIA
....Geshel
--
**********************************************************************
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
**********************************************************************
 
K

Kevin Spencer

There are at least several possibilities. I would suggest that you bone up
on Try/Catch for starters. Some possibilities include:

1. Are you sure that you're always passing in a valid table name?
2. Are you closing your Connections as soon as you're done with them? If so,
how are you sure that you are doing so? Again, bone up on Try/Catch. The
Finally block is the best place to close your Connection. It always
executes.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
N

Neo Geshel

Kevin said:
There are at least several possibilities. I would suggest that you bone up
on Try/Catch for starters. Some possibilities include:

1. Are you sure that you're always passing in a valid table name?
2. Are you closing your Connections as soon as you're done with them? If so,
how are you sure that you are doing so? Again, bone up on Try/Catch. The
Finally block is the best place to close your Connection. It always
executes.

Hmmm.... I do believe that proper table names are being passed along,
but I'm not entirely sure.

You see, I have two database tables. Both are identical, but have to
hold different data. There is an autogenerate ID field, an OLE Image
field, and a Memo Comment field.

The first visit to the page, the visitor is presented with a drop-down
menu, allowing them to choose between the two tables. Once they choose a
table, the table's name is put into a session variable. That session
variable is called whenever reading/editing/adding has to be done by the
resulting datagrid (the same datagrid is powered both tables, hence the
need to put the table name in a session variable... otherwise I'd need
twice the code for two groups of SQL statements).

So an SQL statement would be like this:
Dim myCmd as New OleDbCommand("SELECT * FROM tbl" & Session("ID") & "
ORDER BY [ID]", myConn)
Is there any other way, other than a session variable, that a value can
be kept across multiple page views (of the same page)?

Other than that, is it possible that the connections simply aren't
closing fast enough? That is, data is still being read for image 1 when
the script asks for the data from image 2... and therefore a "collision"
occurs?

TIA
....Geshel
--
**********************************************************************
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
**********************************************************************
 
N

Neo Geshel

Kevin said:
There are at least several possibilities. I would suggest that you bone up
on Try/Catch for starters. Some possibilities include:

1. Are you sure that you're always passing in a valid table name?
2. Are you closing your Connections as soon as you're done with them? If so,
how are you sure that you are doing so? Again, bone up on Try/Catch. The
Finally block is the best place to close your Connection. It always
executes.

I think I managed to solve the problem. It turns out that I was filling
the DataGrid by doing a calling a wildcard SQL command (SELECT * FROM
tbl...), and this action of getting EVERYTHING from the table, including
all of the image data (which is rather useless... the image data needs
to be handled by displayimage.aspx in order to be seen in the
browser...) seems to be the reason why the database call crapped out.

Since the images top out at about 50kb apiece, with about 24 images
being loaded via displayimage.aspx, the simple act of changing the SQL
statement to "SELECT [ID], [Comment] FROM tbl..." has prevented the
problem from happening again.

Your suggestion for Try/Catch is a good one for adding/updating the
data, and I will try to implement it if and when time permits (this is a
family site... so no rush!), but I can't see where implementing it with
database *reads* would help anything. Either the data is there and it
can be read, or it isn't and it can't be read. I can't see why error
handling needs to be implemented in a simple database read. In more
complex environments, I could probably come up with a case in favour,
but not here.

Thanks.

....Geshel
--
**********************************************************************
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
**********************************************************************
 
C

C-Services Holland b.v.

Neo said:
I am working with an Access database, and every now and again I get an
error that forces me to shut down and restart the www service. The
timing is random, and can occur when I am editing, entering or viewing
data. I have Googled this error message, but have gotten nowhere.

The error is:


Server Error in '/' Application.
Unspecified error
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Unspecified error

Source Error:

Line 11: Dim strID as String = Request.QueryString("id")
Line 12: Dim myConn as New
OleDbConnection(ConfigurationSettings.AppSettings("strConn"))
Line 13: myConn.Open()
Line 14: Dim myCmd as New OleDbCommand("SELECT Count(Image) FROM tbl"
& strTable & " WHERE [ID] = " & strID, myConn)
Line 15: If myCmd.ExecuteScalar() <> 0 Then


Source File: C:\Inetpub\wwwroot\kabis.com\hofbrauhaus\image.aspx
Line: 13

Stack Trace:

[OleDbException (0x80004005): Unspecified error]
System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) +20
System.Data.OleDb.OleDbConnection.InitializeProvider() +57
System.Data.OleDb.OleDbConnection.Open() +203
ASP.image_aspx.Page_Load(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\kabis.com\hofbrauhaus\image.aspx:13
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750


Version Information: Microsoft .NET Framework Version:1.1.4322.2300;
ASP.NET Version:1.1.4322.2300



Any clues?? I am mystified.

TIA
...Geshel

I notice you don't enclose your ID string in quotes.
 
K

Kevin Spencer

The first visit to the page, the visitor is presented with a drop-down
menu, allowing them to choose between the two tables. Once they choose a
table, the table's name is put into a session variable. That session
variable is called whenever reading/editing/adding has to be done by the
resulting datagrid (the same datagrid is powered both tables, hence the
need to put the table name in a session variable... otherwise I'd need
twice the code for two groups of SQL statements).

Aha! I would bet that when your Session times out the exception occurs. This
would cause a non-existent table name to be passed into the query!

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

Neo Geshel said:
Kevin said:
There are at least several possibilities. I would suggest that you bone
up on Try/Catch for starters. Some possibilities include:

1. Are you sure that you're always passing in a valid table name?
2. Are you closing your Connections as soon as you're done with them? If
so, how are you sure that you are doing so? Again, bone up on Try/Catch.
The Finally block is the best place to close your Connection. It always
executes.

Hmmm.... I do believe that proper table names are being passed along, but
I'm not entirely sure.

You see, I have two database tables. Both are identical, but have to hold
different data. There is an autogenerate ID field, an OLE Image field, and
a Memo Comment field.

The first visit to the page, the visitor is presented with a drop-down
menu, allowing them to choose between the two tables. Once they choose a
table, the table's name is put into a session variable. That session
variable is called whenever reading/editing/adding has to be done by the
resulting datagrid (the same datagrid is powered both tables, hence the
need to put the table name in a session variable... otherwise I'd need
twice the code for two groups of SQL statements).

So an SQL statement would be like this:
Dim myCmd as New OleDbCommand("SELECT * FROM tbl" & Session("ID") & "
ORDER BY [ID]", myConn)
Is there any other way, other than a session variable, that a value can be
kept across multiple page views (of the same page)?

Other than that, is it possible that the connections simply aren't closing
fast enough? That is, data is still being read for image 1 when the script
asks for the data from image 2... and therefore a "collision" occurs?

TIA
...Geshel
--
**********************************************************************
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
**********************************************************************
 
N

Neo Geshel

C-Services Holland b.v. said:
Neo said:
I am working with an Access database, and every now and again I get an
error that forces me to shut down and restart the www service. The
timing is random, and can occur when I am editing, entering or viewing
data. I have Googled this error message, but have gotten nowhere.

The error is:


Server Error in '/' Application.
Unspecified error
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Unspecified error

Source Error:

Line 11: Dim strID as String = Request.QueryString("id")
Line 12: Dim myConn as New
OleDbConnection(ConfigurationSettings.AppSettings("strConn"))
Line 13: myConn.Open()
Line 14: Dim myCmd as New OleDbCommand("SELECT Count(Image) FROM
tbl" & strTable & " WHERE [ID] = " & strID, myConn)
Line 15: If myCmd.ExecuteScalar() <> 0 Then


Source File: C:\Inetpub\wwwroot\kabis.com\hofbrauhaus\image.aspx
Line: 13

Stack Trace:

[OleDbException (0x80004005): Unspecified error]
System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) +20
System.Data.OleDb.OleDbConnection.InitializeProvider() +57
System.Data.OleDb.OleDbConnection.Open() +203
ASP.image_aspx.Page_Load(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\kabis.com\hofbrauhaus\image.aspx:13
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750


Version Information: Microsoft .NET Framework Version:1.1.4322.2300;
ASP.NET Version:1.1.4322.2300



Any clues?? I am mystified.

TIA
...Geshel


I notice you don't enclose your ID string in quotes.

Nope. Since then I have made a change. The ID string is no longer a
string, but a very severely cast Integer. That way, only an integer can
get passed onto the SQL string. Anything else throws an error (and I've
checked!), preventing SQL injection attacks.

....Geshel
--
**********************************************************************
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
**********************************************************************
 
N

Neo Geshel

Kevin said:
Aha! I would bet that when your Session times out the exception occurs. This
would cause a non-existent table name to be passed into the query!

Actually, the session is created and used at the same time. Every time
the page is loaded/reloaded, the session variable is re-created. That
way, it can't time out.

Good point, but I already thought of that one in advance, and decided
not to risk it.

....Geshel
--
**********************************************************************
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
**********************************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,744
Latest member
CortneyMcK

Latest Threads

Top