3
Answers

Check database connection - asp.net C# razor syntax

Hello guys,
 
The code below is a php code that check if the database connection is open :
 
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?> 
 
I want to do an exact verification but in asp.net c# with razor syntax. my database connection code is below : 
 
var db = Database.Open(client); //client is my connection string defined in my web.config
Answers (3)