Deepthi Aravind

Deepthi Aravind

  • NA
  • 59
  • 105k

connection open problem

Oct 25 2010 2:52 AM

Hi
   I am trying to establish connection to remote sql server through my c# code.
This is working fine when i tried connect to local server.

private static string _ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["connectionstring"].ToString();
SqlConnection _con =
new SqlConnection(_ConnectionString );

if (_con.State == ConnectionState.Open)
{
_con.Close();
}
_con.Open();
Before executing _con.open,I m geting dis error
+  ServerVersion '_con.ServerVersion' threw an exception of type 'System.InvalidOperationException' string {System.InvalidOperationException}
Please help me .Its very urgent..
 
Regards
Deepthi

Answers (6)