IDataAccessLayer
-
ugh. if only we all understood how static works... and perhaps naming conventions... hmm, i guess understanding when to apply the word "static" to a class might also be helpful... i don't even care about the bad use of List<SqlParameter>. Oh and don't worry, there were comments for the functions, the class, the property, and of course i didn't remove the one inside the constructor...
public class IDataAccesslayer
{
private static SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["connStr"].ToString());public IDataAccesslayer() { // // TODO: Add constructor logic here // } public static void ExecuteNoReturn(String spName, List<SqlParameter> parms) { try { conn.Open(); SqlCommand cmd = new SqlCommand(spName, conn); cmd.CommandType = CommandType.StoredProcedure; foreach (SqlParameter parm in parms) { cmd.Parameters.Add(parm); } cmd.ExecuteNonQuery(); } catch (Exception ex) { throw (ex); } finally { if (conn.State == ConnectionState.Open) conn.Close(); } } public static DataSet ExecuteReturnDataSet(String spName, List<SqlParameter> parms) { //this was same as previous, except using a data-adapter }
}
-
ugh. if only we all understood how static works... and perhaps naming conventions... hmm, i guess understanding when to apply the word "static" to a class might also be helpful... i don't even care about the bad use of List<SqlParameter>. Oh and don't worry, there were comments for the functions, the class, the property, and of course i didn't remove the one inside the constructor...
public class IDataAccesslayer
{
private static SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["connStr"].ToString());public IDataAccesslayer() { // // TODO: Add constructor logic here // } public static void ExecuteNoReturn(String spName, List<SqlParameter> parms) { try { conn.Open(); SqlCommand cmd = new SqlCommand(spName, conn); cmd.CommandType = CommandType.StoredProcedure; foreach (SqlParameter parm in parms) { cmd.Parameters.Add(parm); } cmd.ExecuteNonQuery(); } catch (Exception ex) { throw (ex); } finally { if (conn.State == ConnectionState.Open) conn.Close(); } } public static DataSet ExecuteReturnDataSet(String spName, List<SqlParameter> parms) { //this was same as previous, except using a data-adapter }
}
-
ugh. if only we all understood how static works... and perhaps naming conventions... hmm, i guess understanding when to apply the word "static" to a class might also be helpful... i don't even care about the bad use of List<SqlParameter>. Oh and don't worry, there were comments for the functions, the class, the property, and of course i didn't remove the one inside the constructor...
public class IDataAccesslayer
{
private static SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["connStr"].ToString());public IDataAccesslayer() { // // TODO: Add constructor logic here // } public static void ExecuteNoReturn(String spName, List<SqlParameter> parms) { try { conn.Open(); SqlCommand cmd = new SqlCommand(spName, conn); cmd.CommandType = CommandType.StoredProcedure; foreach (SqlParameter parm in parms) { cmd.Parameters.Add(parm); } cmd.ExecuteNonQuery(); } catch (Exception ex) { throw (ex); } finally { if (conn.State == ConnectionState.Open) conn.Close(); } } public static DataSet ExecuteReturnDataSet(String spName, List<SqlParameter> parms) { //this was same as previous, except using a data-adapter }
}
I also like: WebConfigurationManager.ConnectionStrings("connStr").ToString() Maybe he wasn't confident enough that WebConfigurationManager.ConnectionStrings("connStr") would return a string. Maybe he should be sure with: WebConfigurationManager.ConnectionStrings("connStr").ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString()
-
ugh. if only we all understood how static works... and perhaps naming conventions... hmm, i guess understanding when to apply the word "static" to a class might also be helpful... i don't even care about the bad use of List<SqlParameter>. Oh and don't worry, there were comments for the functions, the class, the property, and of course i didn't remove the one inside the constructor...
public class IDataAccesslayer
{
private static SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["connStr"].ToString());public IDataAccesslayer() { // // TODO: Add constructor logic here // } public static void ExecuteNoReturn(String spName, List<SqlParameter> parms) { try { conn.Open(); SqlCommand cmd = new SqlCommand(spName, conn); cmd.CommandType = CommandType.StoredProcedure; foreach (SqlParameter parm in parms) { cmd.Parameters.Add(parm); } cmd.ExecuteNonQuery(); } catch (Exception ex) { throw (ex); } finally { if (conn.State == ConnectionState.Open) conn.Close(); } } public static DataSet ExecuteReturnDataSet(String spName, List<SqlParameter> parms) { //this was same as previous, except using a data-adapter }
}
-
Gaaah!!!
throw new Stone();
Agh! Reality! My Archnemesis![^]
| FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy