static object ExecuteScalar(string sql, object[] values) { Log.debug("Sql scalar: " + sql); using (MySqlConnection connection = new MySqlConnection(connectionString)) { using (MySqlCommand command = new MySqlCommand(sql, connection)) { SetParameters(command, values); connection.Open(); return(command.ExecuteScalar()); } } }
static int ExecuteNonQuery(string sql, object[] values) { Log.debug("Sql non-query: " + sql); using (MySqlConnection connection = new MySqlConnection(connectionString)) { using (MySqlCommand command = new MySqlCommand(sql, connection)) { SetParameters(command, values); connection.Open(); return(command.ExecuteNonQuery()); } } }
public static HttpContentType FromFileName(string path) { Debug.Assert(path != null && path.Trim().Length > 0 && path.Trim().Equals(path)); foreach (HttpContentType type in AllTypes) { foreach (string extension in type.fileExtensions) { if (path.EndsWith(extension, StringComparison.CurrentCultureIgnoreCase)) { return(type); } } } Log.debug("Unknown content type for file: " + path); return(UnknownContentType); }
static void ExecuteReader(string sql, object[] vars, List <object[]> resultsList) { Log.debug("Sql reader: " + sql); using (MySqlConnection connection = new MySqlConnection(connectionString)) { using (MySqlCommand command = new MySqlCommand(sql, connection)) { SetParameters(command, vars); connection.Open(); using (MySqlDataReader reader = command.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { object[] values = new object[reader.FieldCount]; reader.GetValues(values); resultsList.Add(values); } } } } } }