public int ExecuteData(string sql) { int i; SqlConnection conn = new ConnectDB2().connection(); SqlCommand cmd = new SqlCommand(sql, conn); conn.Open(); i = cmd.ExecuteNonQuery(); conn.Close(); return(i); }
public int ExecuteData(string sql, SqlParameterCollection parameters) { int i; SqlConnection conn = new ConnectDB2().connection(); SqlCommand cmd = new SqlCommand(sql, conn); foreach (SqlParameter param in parameters) { cmd.Parameters.AddWithValue(param.ParameterName, param.SqlDbType).Value = param.Value; } conn.Open(); i = cmd.ExecuteNonQuery(); conn.Close(); return(i); }