GettingConnection using SQL in CSharp
I want to generalise the getting connection for that I write a method in C# Class file like this
public SqlConnection GetConnection(SqlConnection objSqlCon)
{
SqlConnection con = new SqlConnection();
try
{
objSqlCon.ConnectionString = con.ConnectionString();
objSqlCon.Open();
return objSqlCon;
}
catch(Exception e)
{
}
}
it shows an error like this
'System.Data.SqlClient.SqlConnection.ConnectionString' is a 'property' but is used like a 'method'
or else can u please tell me the another way to get connection by passing sqlconnection to that method.
Thanks in Advance.