Database connection methods

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

  // Execute non query SQL statement, and returns the number of rows affected

public static int ExecuteNonQuery(string sql, params SqlParameter[] sqlparams)

{

using (SqlConnection conn = new SqlConnection(ConStr))

{

conn.Open();

using (SqlCommand cmd = new SqlCommand(sql, conn))

{

foreach (SqlParameter sqlparam in sqlparams)

{

cmd.Parameters.Add(sqlparam);

}

return cmd.ExecuteNonQuery();

}

}

}

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Ternence at November 15, 2013 - 3:28 PM