H
HillBilly
This is freaking me out. I'm using Membership and trying to determine if the
database is online. The GetConnectionString( ) 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.Redirect 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_Click(object sender, EventArgs e)
{
// Redirect proves this test works
//Response.Redirect(ResolveUrl("~/homepage.aspx?LoginButton_Click"));
SqlConnection testConnection = new
SqlConnection(GetConnectionString("MyConnectionString"));
if (!String.IsNullOrEmpty(testConnection.ToString()))
{
try
{
//testConnection.Open();
//testConnection.Close();
Response.Redirect(ResolveUrl("~/homepage.aspx?MyConnectionString-Found"));
}
catch (Exception ex)
{
Response.Redirect(ResolveUrl("~/homepage.aspx?LoginButton_Click-Caught-Exception"));
}
}
}
database is online. The GetConnectionString( ) 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.Redirect 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_Click(object sender, EventArgs e)
{
// Redirect proves this test works
//Response.Redirect(ResolveUrl("~/homepage.aspx?LoginButton_Click"));
SqlConnection testConnection = new
SqlConnection(GetConnectionString("MyConnectionString"));
if (!String.IsNullOrEmpty(testConnection.ToString()))
{
try
{
//testConnection.Open();
//testConnection.Close();
Response.Redirect(ResolveUrl("~/homepage.aspx?MyConnectionString-Found"));
}
catch (Exception ex)
{
Response.Redirect(ResolveUrl("~/homepage.aspx?LoginButton_Click-Caught-Exception"));
}
}
}