473,386 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Error handling

When your program gets an error, is there a name of that Exception somewhere
on that error page so that you can trap it with the correct exception name?
For instance, I errored when attempting to bind a grid, because a field
didn't exist in the query that was on the grid. How do I find the name of
the exception and trap the error? The error I received said:

A field or property with the name 'ID' was not found on the selected
datasource.
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.Web.HttpException: A field or property with the
name 'ID' was not found on the selected datasource.

Source Error:
Line 314: HTTPContext.Current.Session("DS") = ds
Line 315: dgrid.DataSource = ds
Line 316: dgrid.DataBind()
Line 317:
Line 318: End Sub
Source File: C:\Inetpub\wwwroot\WebApplication1\default.aspx Line: 316

Stack Trace:
[HttpException (0x80004005): A field or property with the name 'ID' was not
found on the selected datasource.]
System.Web.UI.WebControls.BoundColumn.OnDataBindCo lumn(Object sender,
EventArgs e) +346
System.Web.UI.Control.OnDataBinding(EventArgs e) +66
System.Web.UI.Control.DataBind() +26
System.Web.UI.Control.DataBind() +86
System.Web.UI.WebControls.DataGrid.CreateItem(Int3 2 itemIndex, Int32
dataSourceIndex, ListItemType itemType, Boolean dataBind, Object dataItem,
DataGridColumn[] columns, TableRowCollection rows, PagedDataSource
pagedDataSource) +169
System.Web.UI.WebControls.DataGrid.CreateControlHi erarchy(Boolean
useDataSource) +1408
System.Web.UI.WebControls.BaseDataList.OnDataBindi ng(EventArgs e) +48
System.Web.UI.WebControls.BaseDataList.DataBind() +23

Nov 19 '05 #1
2 1886
How do I find the name of
the exception and trap the error? Exception Details: System.Web.HttpException:
...and you can catch it with either a Try/Catch block, or fix it by fixing
your code.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
"Iams" <Iams@hotmail> wrote in message
news:uo*************@TK2MSFTNGP14.phx.gbl... When your program gets an error, is there a name of that Exception
somewhere
on that error page so that you can trap it with the correct exception
name?
For instance, I errored when attempting to bind a grid, because a field
didn't exist in the query that was on the grid. How do I find the name of
the exception and trap the error? The error I received said:

A field or property with the name 'ID' was not found on the selected
datasource.
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.Web.HttpException: A field or property with the
name 'ID' was not found on the selected datasource.

Source Error:
Line 314: HTTPContext.Current.Session("DS") = ds
Line 315: dgrid.DataSource = ds
Line 316: dgrid.DataBind()
Line 317:
Line 318: End Sub
Source File: C:\Inetpub\wwwroot\WebApplication1\default.aspx Line: 316

Stack Trace:
[HttpException (0x80004005): A field or property with the name 'ID' was
not
found on the selected datasource.]
System.Web.UI.WebControls.BoundColumn.OnDataBindCo lumn(Object sender,
EventArgs e) +346
System.Web.UI.Control.OnDataBinding(EventArgs e) +66
System.Web.UI.Control.DataBind() +26
System.Web.UI.Control.DataBind() +86
System.Web.UI.WebControls.DataGrid.CreateItem(Int3 2 itemIndex, Int32
dataSourceIndex, ListItemType itemType, Boolean dataBind, Object dataItem,
DataGridColumn[] columns, TableRowCollection rows, PagedDataSource
pagedDataSource) +169
System.Web.UI.WebControls.DataGrid.CreateControlHi erarchy(Boolean
useDataSource) +1408
System.Web.UI.WebControls.BaseDataList.OnDataBindi ng(EventArgs e) +48
System.Web.UI.WebControls.BaseDataList.DataBind() +23

Nov 19 '05 #2
The code isn't my problem, I have other users who modify the database that
the program is hitting, so I need specific error messages, in this case, the
fact that someone deleted a column that my datagrid is referring to. How do
I distinguish between an error where a column is missing and any other
datagrid errors I may encounter? I want the program to do different things
depending on what caused the error. Do I have to interpret the actual
message, like we did in old vb, to fire events based on what the actual
error is? I guess what I'm looking for are already-built exceptions, like
the ArgumentOutOfRangeException, or ArgumentNullexception you can use when
values are empty.

Try
dgrid.DataBind()
Catch ex as System.Web.HttpException 'error due to missing column in
database
HTTPContext.Current.Session("Status") = ex.Message
End Try

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:ed**************@TK2MSFTNGP12.phx.gbl...
How do I find the name of
the exception and trap the error?

Exception Details: System.Web.HttpException:


..and you can catch it with either a Try/Catch block, or fix it by fixing
your code.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.
"Iams" <Iams@hotmail> wrote in message
news:uo*************@TK2MSFTNGP14.phx.gbl...
When your program gets an error, is there a name of that Exception
somewhere
on that error page so that you can trap it with the correct exception
name?
For instance, I errored when attempting to bind a grid, because a field
didn't exist in the query that was on the grid. How do I find the name of the exception and trap the error? The error I received said:

A field or property with the name 'ID' was not found on the selected
datasource.
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.Web.HttpException: A field or property with the name 'ID' was not found on the selected datasource.

Source Error:
Line 314: HTTPContext.Current.Session("DS") = ds
Line 315: dgrid.DataSource = ds
Line 316: dgrid.DataBind()
Line 317:
Line 318: End Sub
Source File: C:\Inetpub\wwwroot\WebApplication1\default.aspx Line: 316
Stack Trace:
[HttpException (0x80004005): A field or property with the name 'ID' was
not
found on the selected datasource.]
System.Web.UI.WebControls.BoundColumn.OnDataBindCo lumn(Object sender,
EventArgs e) +346
System.Web.UI.Control.OnDataBinding(EventArgs e) +66
System.Web.UI.Control.DataBind() +26
System.Web.UI.Control.DataBind() +86
System.Web.UI.WebControls.DataGrid.CreateItem(Int3 2 itemIndex, Int32
dataSourceIndex, ListItemType itemType, Boolean dataBind, Object dataItem, DataGridColumn[] columns, TableRowCollection rows, PagedDataSource
pagedDataSource) +169
System.Web.UI.WebControls.DataGrid.CreateControlHi erarchy(Boolean
useDataSource) +1408
System.Web.UI.WebControls.BaseDataList.OnDataBindi ng(EventArgs e) +48
System.Web.UI.WebControls.BaseDataList.DataBind() +23


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: WSeeger | last post by:
When creating a new class, is it encouraged to always include error handling routines within your LET and GET procedures? It's seems that most text books never seem to include much about error...
12
by: Christian Christmann | last post by:
Hi, assert and error handling can be used for similar purposes. When should one use assert instead of try/catch and in which cases the error handling is preferable? I've read somewhere that...
6
by: Squirrel | last post by:
I have a command button on a subform to delete a record. The only statement in the subroutine is: DoCmd.RunCommand acCmdDeleteRecord The subform's recordsource is "select * from tblVisit order...
13
by: Thelma Lubkin | last post by:
I use code extensively; I probably overuse it. But I've been using error trapping very sparingly, and now I've been trapped by that. A form that works for me on the system I'm using, apparently...
21
by: Anthony England | last post by:
Everyone knows that global variables get re-set in an mdb when an un-handled error is encountered, but it seems that this also happens when the variable is defined as private at form-level. So...
3
by: Stefan Johansson | last post by:
Hi all I'am moving from Visual Foxpro and have a question regarding "best practice" error handling in vb .net. In VFP I have always used a "central" error handling object in order to have a...
4
by: Al Williams | last post by:
Hi, I have error handling in place throughout my application. I also start the application wrapped in error handling code to catch any unexpected exceptions (i.e. exceptions that occur where I...
10
by: Anthony England | last post by:
(sorry for the likely repost, but it is still not showing on my news server and after that much typing, I don't want to lose it) I am considering general error handling routines and have...
0
by: Lysander | last post by:
Thought I would give something back with a few articles. This article is a bit of code to add error handling. When I have time, I want to write articles on multilingual databases, and Access...
9
by: MrDeej | last post by:
Hello guys! We have an SQL server which sometimes makes timeouts and connection errors. And we have an function witch writes and updates data in 2 tables on this server. When the SQL server error...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
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...
1
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...
0
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.