Accessing the database - use System.Web.UI.Page

Hi

I'd like to know if the following is the best way to allow for catching exceptions!
I have a class separate from my web form stuff which accesses the database and so that I can use the Response.Write to display exception messages when accessing the database I have added System.Web.UI.Page to the class TaskDB as follows:
public class TaskDB : System.Web.UI.Page
{
public OleDbDataReader GetTaskDetails(String projectname)
{
//code to setup accessing the database is here
try
{
myConnection.Open();
myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
}
catch (OleDbException e)
{
Response.Write(e.Message);
Response.End();
myConnection.Close();
}
return myReader;
}
}
Is this a good thing? I can't seem to use Response without doing this - is there another better way?
Thanks in advance.
0
catm
12/3/2003 4:37:28 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

0 Replies
650 Views

Similar Articles

[PageSpeed] 52

Reply:

Similar Artilces:

System.Web.UI.Page and System.Web.UI.UserControl
the below code works great for myBasePage.cs that inherits from : System.Web.UI.Page and the same code i copied to another base class which is myBaseControl.cs that inherits from : System.Web.UI.UserControlthe below code does not work for myBaseControl.cs and after i look at the MSDN i found that i have to use   SaveViewState()LoadViewStatemy qustion is how do i make my code use the above two methods (SaveViewState & LoadViewState) ? protected override void SavePageStateToPersistenceMedium(object viewState){string key = Request.Url.ToString() + "__VIEWSTATE";System.IO.Memo...

'Void System.Web.UI.ScriptManager.RegisterHiddenField(System.Web.UI.Page, System.String, System.String)'
It code worked fine on my PC..but gettting following message on server.... 'Void System.Web.UI.ScriptManager.RegisterHiddenField(System.Web.UI.Page, System.String, System.String)'  i checked this thread http://forums.asp.net/p/1123792/1869084.aspx#1869084  but it doesn't help me...  My Blog"Don't be afraid to be wrong; otherwise you'll never be right." Updating global assembly cache of server, solved this error Some how installation is not updating GAC..so you have to do it manuallyMy Blog"Don't be afraid to be wrong; otherwis...

Method not found: 'Void System.Web.UI.ScriptManager.RegisterHiddenField(System.Web.UI.Page, System.String, System.String)'
I downloaded the 10618 version and can not get it working.  The sample website that comes with the release gives me this error on every page I try to browse. Method not found: 'Void System.Web.UI.ScriptManager.RegisterHiddenField(System.Web.UI.Page, System.String, System.String)' Stack Trace: [MissingMethodException: Method not found: 'Void System.Web.UI.ScriptManager.RegisterHiddenField(System.Web.UI.Page, System.String, System.String)'.]   AjaxControlToolkit.ToolkitScriptManager.OnLoad(EventArgs e) +0   System.Web.UI.Control.LoadRecursive() +47&n...

Method not found: 'Void System.Web.UI.ScriptManager.RegisterHiddenField(System.Web.UI.Page, System.String, System.String)'. error
Hi,  I have used the Animation control of the Ajax Control Toolkit successfully on my local PC. The web site was successfully launched on a third party hosting company. Recently, I had to change to another third party hosting company and now I get the following error on the page where I used the Animation control. All other pages are working fine. Does any one know how I can resolve this error?   Method not found: 'Void System.Web.UI.ScriptManager.RegisterHiddenField(System.Web.UI.Page, System.String, System.String)'. Description: An unhandled exception occurred during t...

Error Message: Method not found: 'Void System.Web.UI.ScriptManager.RegisterClientScriptBlock(System.Web.UI.Page, System.Type, System.String, System.String, Boolean)'.
  I have a website which is running on IIS 5.1. Wen ever I am trying to access any page based on .net framework 2.0 I get this error Error Message: Method not found: 'Void System.Web.UI.ScriptManager.RegisterClientScriptBlock(System.Web.UI.Page, ...

Understanding Web Form System.Web.UI.Page.ProcessRequest
Hello all ... I'm working with a third-party product that monitors .NET and ASP.NET performance.  This product monitors performance times for "entry points" ... essentially how long it takes to load an .aspx page, etc.  Pretty slick. The "entry point" they use to start tracking time on a Web page is System.Web.UI.Page.ProcessRequest      I looked this up in the docs, and it says this is one of the features available in ASP.NET that really isn't intended for developers to use.  OK, fair enough.  I as a developer shouldn't use it....

System.Web.UI.ClientScriptManager.ClientScriptManager(System.Web.UI.Page)' is inaccessible due to its protection level
I get this error when I try to add a client script to a page from codebehind. "System.Web.UI.ClientScriptManager.ClientScriptManager(System.Web.UI.Page)' is inaccessible due to its protection level"I get full intellisense when I type the code, but there is a red line under "new ClientScriptManager();"ClientScriptManager ClientScript = new ClientScriptManager();        ClientScript.RegisterStartupScript(HttpContext.Current.GetType(), "onLoadCall", "<script language='javascript'></script>"); I...

Warning 4 'System.Web.UI.Page.GetPostBackEventReference(System.Web.UI.Control, string)' is obsolete
Hi I am using the following code in an ASP.NET C# web application: this.Page.GetPostBackEventReference(this, string.Empty);if (this.IsPostBack) {string eventTarget = (this.Request["__EVENTTARGET"] == null) ? string.Empty : this.Request["__EVENTTARGET"]; string eventArgument = (this.Request["__EVENTARGUMENT"] == null) ? string.Empty : this.Request["__EVENTARGUMENT"];if (eventTarget == "ForcedPostBack") { // This was a PostBack from the client-side forcedPostBack function... // eventArgument will equal "Some value to send server-...

Can my web page with a form submit to other web pages forms?
I was wondering if I created an aspx page that had a form on it that I could use the submit button to submit this form's contents to other web pages forms(servers accepting those form's data). I am thinking this would be a great way to update data on particular web pages without having to actually visit those similar web pages. Any ideas, examples would be much appreciated. Thanks in advance.  Yes you can.  It's called Cross Page Posting: http://msdn2.microsoft.com/en-us/library/ms178139.aspxAlso: http://msdn2.microsoft.com/en-us/library/ms178140.aspx might ...

Upcast System.Web.UI.Control to System.Web.UI.WebControl?
I'm getting a "Specified cast is invalid" error when trying the following: WebControl wc = (WebControl)control; Where "control" is a System.Web.UI.Control inherited from a ControlsCollection (Panel.Controls). Is it possible to upcast from Control to WebControl? Seems silly not to considering the Control is a TextBox or CheckBox which inherits from WebControl. If this isn't possible... how can I access the "Attributes" of a Control? If it were a WebControl, I'd do the following: wc.Attributes["onclick"] = "...

direct cast system.web.ui.control to system.web.ui.webcontrol
Hello, I have a class that loops through all of the page's controls before Page_Load, and ads them the eppropriate attribute based on an xml file. I initially only had labels and buttons that needed to be added some attributes, but I would like to ad an attribute to a HyperLinkField inside a GridView. I am having problems casting my control to a WebControl. This is the lines: Dim cntrl As Control = FindControlRecursive(Page.Form, SubxmlReader.Name)  'this is just to find the control I need Dim hpf As HyperLinkField = TryCast(cntrl, HyperLinkField) On the second line,...

System.Web.UI.Page and Ajax.net
 ─░ use .net 2005 and ajax.net.Normally i use System.Web.UI.Page,my webpage is working.But in here we use other page that extends System.Web.UI.Page.if i extend my class to our  webpage my ajax.net isn't  working. My error explanation is: sys.webfrom.pagerequestmanagerparserErrorException:the message received from the server could not beparsed.Common causes for this error are when the response is modifies by calls to Response.write(),response filters,httpmodules,or server trace is enabled. Details:Error parsing near'itle||Untitled PAge|<script language=J...

web web web
Name: bahadir Email: sensiz_olmuyor_t1_at_hotmail.com Product: Firefox 2 Beta 2 Summary: web web web Comments: web sayfas─▒ yapmak Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.8.1b2) Gecko/20060821 Firefox/2.0b2 ...

its type (System.Web.UI.ScriptManager) is not compatible with the type of control (System.Web.UI.ScriptManager).
Parser Error Message: The base class includes the field 'ScriptManager1', but its type (System.Web.UI.ScriptManager) is not compatible with the type of control (System.Web.UI.ScriptManager). Line 19: <div class="demo-area">Line 20:   <asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server" /> I dragged a scriptManager control from the toolbox (also having same problem with an UpdatePanel control), and when I try to run the webapp, I get the error message above - specifically - in the ...

How to access a control on a web form from anoter web form
hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it possible to access lbl1 from form2, change its text permenantly? thanks.   refer: http://dotnetslackers.com/Community/blogs/haissam/archive/2007/11/26/ways-to-pass-data-between-webforms.aspxSSNPlease remember to click "Mark as Answer" on the post that helps you. MinaSamy: hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it p...

Web resources about - Accessing the database - use System.Web.UI.Page - asp.net.web-forms

Highest Percentage Of Opera Mini Users Accessing Facebook? Macau
If you were asked to guess which country had the highest percentage of users of Opera mobile Web browser Opera Mini users accessing Facebook ...

International Users Accessing Facebook Places Through US VPN Accounts
By using a virtual private network (VPN) hosted in the United States, Facebook users from around the world are accessing Facebook Places. The ...

What are some alternatives to Yodlee for accessing bank information?
Clay Loveless , Founder, Jexy. Co-founder, Mashery. Founder, Jexy. Co-founder, Mashery.

Cloud Console - Accessing files in cloud storage for iPad on the iTunes App Store
Get Cloud Console - Accessing files in cloud storage on the App Store. See screenshots and ratings, and read customer reviews.

Meryl Streep On Accessing The Characters Within - YouTube
Meryl Streep talks about the importance of an actors work representing their ability. CONNECT WITH AFI: http://facebook.com/AmericanFilmInstitute ...

Student pleads guilty to accessing records about Frances Abbott design scholarship
The Sydney student who leaked information about a fashion school scholarship controversially awarded to the daughter of the Prime Minister has ...

Accessing a headline opinion
Accessing a headline opinion

Sharp increase in authorities accessing private data
Australian law enforcement and government agencies have sharply increased their access without warrant to vast quantities of private telephone ...

Former librarian charged with accessing student records of Frances Abbott
A former part-time librarian at a Sydney design school has been charged after she allegedly accessed student records of Prime Minister Tony Abbott's ...

Frances Abbott scholarship: Sydney woman pleads guilty to accessing Whitehouse Institute records on PM's ...
A Sydney woman who leaked the student records of Tony Abbott's daughter pleads guilty. A Sydney woman who leaked the student records of Prime ...

Resources last updated: 1/17/2016 7:36:20 AM