>public virtual IDbConnection GetConnection() // or abstract instead of virtual, either way is ok >{ > // ... >} >>
>public override IDbConnection GetConnection() >{ > // Get the connection string > string sConnString = _GetConnString(); > > // Create a connection and assign the connection string to it > SqlConnection oConn = new SqlConnection(); > > // etc.etc.etc. > > return oConn; >} >>
>>public SqlConnection GetConnection() >>{ >> // Get the connection string >> string sConnString = _GetConnString(); >> >> // Create a connection and assign the connection string to it >> SqlConnection oConn = new SqlConnection(); >> oConn.ConnectionString = sConnString; >> >> // Try to open the connection >> try >> { >> oConn.Open(); >> } >> catch (SqlException e) >> { >> } >> >> >> // Test the connection and if the connection was opened, return the connection >> // otherwise return null >> if (oConn.State == ConnectionState.Open) >> { >> // Return the connection >> return oConn; >> } >> else >> { >> return null; >> } >> >>} >> >>>>