Stop Other Sub Proc From Executing After Error "database Is Not Available"

Jan 31, 2011

I am having a problem with my try catch block runs in the error "dastabase is not available". My problem is the try catch runs and catches the error, but it will not redirect to my error page. The code continues to execute the other subs. I have tried adding: exit, return, response.end. None of them worked.

Imports System.Data
Imports EUC
Imports System.Threading
Imports System.Data.SqlClient
Partial Class mpMain
Inherits System.Web.UI.MasterPage
Dim strSQL As String
Dim objData As clsDataAccess = New clsDataAccess()
Dim ds As New DataSet
Dim t1 As DataTable
Dim intSecurityLevel As String = 0
Dim strUser As String = UCase(Right(HttpContext.Current.User.Identity.Name.ToString(), 4))
Protected Sub ExpandNode(ByVal NodeName As String, ByVal PageName As String)
'More Code
End Sub
Protected Sub ExpandNode2(ByVal NodeNameMain As String, ByVal NodeName As String, ByVal PageName As String)
'More Code
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not (IsPostBack) Then
Try
strSQL = "Select SecurityLevel from tblSecurity where SFID = @SFID order by SecurityLevel"
Dim MyParameters1 As SqlParameter() = { _
New SqlParameter("@SFID", SqlDbType.VarChar) _
}
MyParameters1(0).Value = UCase(Right(HttpContext.Current.User.Identity.Name.ToString(), 4))
ds = objData.SQLExecuteDataset(strSQL, CommandType.Text, MyParameters1)
t1 = ds.Tables(0)
Catch ex As Exception
Dim sendError As New clsExceptionMessage
sendError.sendMessage(ex.Message, Request.Path, strSQL)
Response.Redirect("ErrorMessage.aspx", False)
End Try
End If
End Sub
Protected Sub TreeView1_TreeNodeDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) Handles TreeView1.TreeNodeDataBound
'More Code
End Sub
Protected Sub TreeView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.DataBound
'More Code
End Sub
End Class

View 1 Replies


Similar Messages:

C# - Error When Executing A Stored Proc

Aug 17, 2010

I am attempting to execute a stored proc in asp.net in the code behind. The parameter I am trying to pass is strErrorMessage that contains a value of "The transport failed to connect to the server.; ". The error message when the query gets executed is: The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 1 ("@errMessage"): Data type 0xE7 has an invalid data length or metadata length. Update with code

try
{
...
...
...
}
catch (Exception ex)
{
ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Email was not sent - " + ex.Message + "');", true);
string strMessage = ex.Message;
string strStackTrace = ex.StackTrace;
strMessage = strMessage.Replace("
", "; ");
strMessage = strMessage.Replace(" ", "");
strStackTrace = strStackTrace.Replace("
", "; ");
strStackTrace = strStackTrace.Replace(" ", "");
AppErrorLog(strMessage, strStackTrace);
return false;
}
protected void AppErrorLog(string strErrorMessage, string strErrorStackTrace)
{
SqlConnection conErrLog = new SqlConnection(strConn);
string sql = "usp_AppErrorLog_AddRecord";
SqlCommand cmdErrLog = new SqlCommand(sql, conErrLog);
conErrLog.Open();
try
{
cmdErrLog.CommandType = CommandType.StoredProcedure;
cmdErrLog.Parameters.Add(new SqlParameter("@errMessage", SqlDbType.NVarChar, 8000));
cmdErrLog.Parameters["@errMessage"].Value = strErrorMessage;
cmdErrLog.Parameters.Add(new SqlParameter("@errStackTrace", SqlDbType.NVarChar, 8000));
cmdErrLog.Parameters["@errStackTrace"].Value = strErrorStackTrace;
cmdErrLog.Parameters.Add(new SqlParameter("@userID", SqlDbType.VarChar, 12));
cmdErrLog.Parameters["@userID"].Value = User.Identity.Name;
SqlDataAdapter ada = new SqlDataAdapter(cmdErrLog);
cmdErrLog.ExecuteNonQuery();
}
catch(Exception e)
{
ClientScript.RegisterStartupScript(GetType(), "alert", "alert('AppErrorLog - " + e.Message + "');", true);
}
finally
{
conErrLog.Close();
}
}

The column datatype in the table is nvarchar(MAX).

View 4 Replies

C# - Work Continuously On Other Pages While Executing Stored Proc?

Jul 28, 2010

I have a stored procedure that I need to execute from asp.net button , It takes more than 30 mins to execute. So here I need to show a message like "In Process" while execution and disable couple of links..Once the execution is done I need to show "Last processed data and time" and enable the disabled links. So in "In Process" stage we have to allow user to access other pages in the site. How it is possible?

View 2 Replies

VS2010: Executing Parameter Less Stored Proc To Update Record

Apr 28, 2010

I would like to execute a stored proc that simply updates a record. At this point I would like to keep it parameter less. But in future, I will be adding parameters to the stored proc. Can I simply do it via SQLDataSource? It will save me writing few lines of code to execute stored proc in a traditional ado.net.

View 1 Replies

How To Stop The Whole Page From Executing Again When Doing A Postback

Sep 27, 2010

firstly i am not really an ASP.Net developer but i do work in C#.

Anyway one of the application that i develop has an ASP.Net section and i need to amend it.

I want to add a Checkbox which when Checked by the User will set a Session variable.

This Session variable will then be accessed on another page where it will include/disclude some SQL and therefore change the behaviour of a Search.

So i have 2 Pages - Page1 that has the Checkbox on it -

HTML

Quote:

[code]....

1, How do i stop the whole page from executing again when doing a postback ? I only want the Changed Event to run not the whole page

View 11 Replies

Web Forms :: How To Stop Executing Code Behind File

Sep 7, 2010

Using Javascript i am validating a textbox data.when validation fails i need to stop executing code behind file.How to proceed.

View 3 Replies

MVC :: Stop Code From Executing In Initialize() Method?

Jul 29, 2010

in my controller I have code that validates URL. if not valid I want it to 301 redirect:

[code]....

but this still goes continues on and executes any code after. how would i simply 301 redirect? and NOT continue to process any code after break;?

View 3 Replies

Security :: Stop Malicious Javascript From Executing?

Jun 15, 2010

I have a web application where I want to stop any malicious JS to execute.

For example:

http://www.mywebsite.com/default.aspx?ID=<script>alert("hello")</script>

If a client does the above then an alert box pops up on the client screen. How to stop that.?

Also I have set validateRequest="true" in the machine.config but still the JS does get execute.

View 5 Replies

Forms Data Controls :: Stop Executing Delete Action?

Apr 1, 2010

if I am running a detailsView_Deleting code and a condition is not met and I want to Cancel the delete, how do I code it?

View 4 Replies

Web Forms :: WCF - When Connection Time Out In The Calling Client - How To Stop Service From Executing

Jun 16, 2010

I have a WCF service that processes some input arguments and retuns result in approximately 4 minutes. Sometimes the calling client may get request time out before the WCF service answers.

Now, my customer is asking me to stop processing on the service side when the client got timed out. Since, I could not know the status of cleint on the service, I could not stop the process.

View 1 Replies

Web Forms :: Pesky Enter Key / Stop The Buttons On The Master Page From Executing Unless The User Mouses Them?

Feb 7, 2011

I have a page with several asp buttons defined on a Master Page. I only wish these buttons to be activated when they are selected by the mouse click. I have one button on the content of the form, that is the button I want to execute if the user hits enter and it is selected or they use the mouse. So in a nutshell. how do I stop the buttons on the master page from executing unless the user mouses them?

View 1 Replies

Web Forms :: Using Server.Execute Mething With In A Thread Getting Error - Error Executing Child Request

Mar 27, 2010

I want to execute a page with server.execute method with different query string values to the page and write the response to a file. It is working perfect with out threads. whereas, if i am using threads then i am getting "Error executing child request" and some times "Object reference not set to an instance of an object." error. Below is sample code. This is working fime with out threads..if i am using thread only one request is getting executed and all others are giving error.

[code]....

View 7 Replies

SQL Server :: Raise Error Stored Proc?

Mar 16, 2011

I have written a stored proc for raise error.Whenever a customer checks for a record in the DB that doesn't exist in the DB he has to get an error displayed.I have written a stored proc help me on it i know it is wrong suggest me the correct one.

[Code]....

View 5 Replies

Databases :: Error While Getting Record Set From The Stored Proc Of The Oracle

Jan 27, 2011

i am getting this error while fetching select statement in oracle pl/sql proc... ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'SP_CLASS' ORA-06550: line 1, column 7: PL/SQL: Statement ignored My proc is like..PROCEDURE "SP_CLASS" ( iDec IN NUMBER := null, p_ICID in number := null, p_DATA OUT SYS_REFCURSOR) IS BEGIN if(iDec = 1) then open p_DATA for SELECT ICID AS ID, SNAME AS NAME FROM SETUP_CLASS; else if(iDec = 2) then open p_DATA for SELECT ICID AS ID, SNAME AS NAME FROM SETUP_CLASS where ICID = p_ICID ; end if; end if; END;

View 1 Replies

DataSource Controls :: Stored Proc Giving Error?

Feb 2, 2010

This is the sproc

ALTER Procedure [dbo].[spGetGroupDetails]
(
@inUserID Varchar(15),
@inGroupID numeric=0,
@inGroupName varchar(100) = null
)
As

[Code]....

View 2 Replies

DataSource Controls :: DBNull Error Trying To Call Stored Proc?

Jan 7, 2011

I have a recordset in a gridview that comes from an outer joint that creates null values in the recordsetWhen I write to the database using stored proc defined in datasource I get dbnull error.I'm trying to process the onDeleting event in the code behind but don't know what to write or if that's the best wayI need to call a stored proc and if the last parameters value is null then the stored proc does one thing, if it's no null it does something else.However DBNull doesn't ssem to be working.

View 1 Replies

Crystal Reports :: Add Parameter To Stored Proc - SQL State 42000 Native Error

Jan 30, 2011

i hve crystal report which is wrking perfectly fine.. now i want to add paramter to my stored proc... but i am not able to add the same parameter on crystal report..i tried to add parameter in the parameter fields the crystal reports field explorer.. but when i verfiy database it still gives msg stored proc expects parameter which was not supplied..SQL State 42000 native error..

View 2 Replies

SQL Server :: Pass Stored Proc Output To Another Stored Proc?

Jul 28, 2010

i have two stored procs. when th 1st stored proc runs i want to be able to use this value returned from the stored into another stored proc.

my first stored proc is:

[Code]....

which returns [Transfer_stations_Authority_name] = 'Blackpool'

now i want to use this value into my second stored proc@

[Code]....

[Code]....

View 1 Replies

WCF / ASMX :: Error While Executing Stored Procedure On Wcf?

Apr 8, 2010

I use a wcf service to fetch data to a silverlight application, but when I try to execute a stored procedure from the wcf, I get this error..

"Data at the root level is invalid. Line 1, position 1.", this happends here..

Dim MyList = From p In db.StatisticByInvoicingAdressAndDateAndCustID(FromDate, ToDate, CustID)

But when I run the stored procedure on the sql server it works fine and return records, I just don't get it... What is wrong and causing this error?

View 1 Replies

SQL Server :: Error While Executing A SQL Scalar Function?

Nov 1, 2010

CREATE

FUNCTION dbo.ufnGetProductReport(@Pid
int)

RETURNS int

AS

BEGIN[code]....

This is the program. When im trying to execute it with Select * from dbo.ufnGetProductReport(1)

im getting an error Invalid object name ufnGetProductReport

View 2 Replies

ADO.NET :: Finding Error While Executing Stored Procedure

Oct 1, 2010

I have created stored procedure in sql server 2005 and connected that database to asp.net application when i submit a data from application form corresponding stored procedure stored procedure(sp1) giving following error Could not find stored procedure 'sp1'. I have written following code on buttonclick event provide me a solution and point out the error in code if exists

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
DataSet ds = new DataSet();
SqlConnection con;
//Here we declare the parameter which we have to use in our application
SqlCommand cmd = new SqlCommand();
SqlParameter sp12 = new SqlParameter();
SqlParameter sp2 = new SqlParameter();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{...............................................................

View 1 Replies

ADO.NET :: [Entity Framework] Strange Error Executing A Sql Query

Nov 29, 2010

I have a strange error, I've tried to search for it before writing this post but I wasn't able to find out a solution yet.

I'm executing a query using ExecuteStoreQuery against a MySQL database, but it throws an exception reporting that there's a syntax error in my SQL.

I've tried to copy&paste the sql query into the MySQL tool and it works nicely, giving the correct results.

I've tried to open manually the connection and using CreateCommand to use it the "old way".

My query is a bit long, 4000 chars more or less, could it be the problem?

View 4 Replies

RegisterRoutes Web Form - Executing Child Request For Error.aspx

Mar 24, 2010

I am facing a problem related to register routes.

private void RegisterRoutes(RouteCollection Routes) { Route myroute3 = new Route("{controller}", new MyRouteHandler()); Routes.Add(myroute3); }

Now, I intentionally made an error. asp.net not showing the appropriate error but "page not found" When I traced it: its is showing the following stack trace: [URL]
Source: System.Web Message: Error executing child request for Error.aspx. I am not been able to track errors.

View 1 Replies

MVC :: Error Executing Child Request For Handler 'System.Web.Mvc.HttpHandlerUtil'

Sep 15, 2010

I am getting following error in production but the same is not a repro in in local.

> Error executing child request for
> handler
> 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerWrapper'.
> Inner Exception: Exception of type
> 'System.Web.HttpUnhandledException'
> was thrown.

Stack Trace:

[code]....

View 2 Replies

Databases :: Executing Sql Script (oracle) Error / Invalid Character

Sep 22, 2010

i have a problem in executing an sql script [Code]....

the error was : "invalid character"

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved