Question : asp.net page to test database connectivity

Hi
I have a asp.net (VB) page that returns a value from a table in a sql server database. I would like to display my error text on the page if the connection string n the web.cofig fails to connect to the db

Thanks

Answer : asp.net page to test database connectivity

Try:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
try
{
	string strConnection = "-- connection string --- from web.config--";
	SqlConnection objConnection = new SqlConnection(strConnection); 
	objConnection.Open();
	btn.Enabled = true;
	btn.Enabled  = "Test Succeeded"; 
}

catch (Exception ex) 
{

	btn.Enabled = false; 
	btn.Enabled  = "Test Failed!!";
}
Random Solutions  
 
programming4us programming4us