I can set breakpoints all over the place --except-- on the try statement. I
don't see anything unusual --except-- an the Error List states: The variable
'ex' is declared but never used noting if I change (Exception ex) to
(Exception e) I get a different error about the variable already being used
in the same scope.
I set breakpoints and I can read the Call Stack and the Locals window. I
really don't know what to look for that indicates why the code in the try
block will not execute. I can only assume the stupid error about ex which
makes no sense to me may be the problem.
I can see the connection string and know its valid and functional. It may
not be a best practice but I don't know any other way to determine when the
database may be offline so I'm trying to force an exception I could easily
catch if and when the database may be offline by using the
testConnection. Open() method which will open and close if the database is
online but should be caught by the catch block when offline.
This is so strange to me not even this code will allow the redirect in the
try block to execute. The click event keeps executing the code in the catch
LoginButton_Cli ck-Caught-Exception...
protected void LoginButton_Cli ck(object sender, EventArgs e)
{
// Redirect proves this test works
//Response.Redire ct(ResolveUrl(" ~/homepage.aspx?L oginButton_Clic ked"));
if( 1 == 1 )
{
try
{
Response.Redire ct(ResolveUrl(" ~/homepage.aspx?L oginButton_Clic k-Try-Block"));
}
catch (Exception ex)
{
Response.Redire ct(ResolveUrl(" ~/homepage.aspx?L oginButton_Clic k-Caught-Exception"));
}
}
}
"rhaazy" <rh****@gmail.c omwrote in message
news:0c******** *************** ***********@s50 g2000hsb.google groups.com...
On Jul 31, 11:51 pm, "HillBilly" <someb...@somew here.comwrote:
This is freaking me out. I'm using Membership and trying to determine if
the
database is online. The GetConnectionSt ring( ) method returns a connection
string as expected but not when used in the try block.
I have the Open() and Close() methods commented out while using the
Response.Redire ct to test.
The code in the try block as shown will --never execute-- but the code in
the catch block --always executes-- whether the database is online or not.
WTF???
protected void LoginButton_Cli ck(object sender, EventArgs e)
{
// Redirect proves this test works
//Response.Redire ct(ResolveUrl(" ~/homepage.aspx?L oginButton_Clic k"));
SqlConnection testConnection = new
SqlConnection(G etConnectionStr ing("MyConnecti onString"));
if (!String.IsNull OrEmpty(testCon nection.ToStrin g()))
{
try
{
//testConnection. Open();
//testConnection. Close();
Response.Redire ct(ResolveUrl(" ~/homepage.aspx?M yConnectionStri ng-Found"));
}
catch (Exception ex)
{
Response.Redire ct(ResolveUrl(" ~/homepage.aspx?L oginButton_Clic k-Caught-Exce*ption"));
}
}
}- Hide quoted text -
- Show quoted text -
Right before your if statement have the app throw a messagebox with
the contents of the string:
MessageBox.Show (testConnection .ToString());