ashish sadasing

ashish sadasing

  • NA
  • 22
  • 11.3k

Check database connection - asp.net C# razor syntax

May 4 2016 7:40 AM
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)