/// <summary> /// /// </summary> /// <param name="connectionString"></param> /// <param name="commandText"></param> /// <returns></returns> public static IDataReader ExecuteReader(string connectionString, string commandText) { var connection = new MonetDbConnection(connectionString); connection.Open(); var command = new MonetDbCommand(connection) { CommandText = commandText }; return(command.ExecuteReader()); }
public void ZTestConnectionPoolingExceedMax() { var modifiedConnString = TestConnectionString + "poolminimum=1;poolmaximum=20;"; var connections = new MonetDbConnection[21]; for (var i = 0; i < connections.Length; i++) { connections[i] = new MonetDbConnection(modifiedConnString); connections[i].Open(); var cmd = new MonetDbCommand("select 1", connections[i]); cmd.ExecuteScalar(); } foreach (var connection in connections) { connection.Close(); } }
public void CheckIfPoolsAreCorrectlyConstructed() { var modifiedConnString = TestConnectionString + "poolminimum=1;poolmaximum=16;"; var connections = new MonetDbConnection[16]; for (var i = 0; i < connections.Length; i++) { connections[i] = new MonetDbConnection(modifiedConnString); connections[i].Open(); var cmd = new MonetDbCommand("select 1", connections[i]); cmd.ExecuteScalar(); } foreach (var connection in connections) { connection.Close(); } Assert.AreEqual(16, connections.Length); }
/// <summary> /// /// </summary> /// <param name="connectionString"></param> /// <param name="commandText"></param> /// <returns></returns> public static int ExecuteNonQuery(string connectionString, string commandText) { int result; using (var connection = new MonetDbConnection(connectionString)) { connection.Open(); using (var command = new MonetDbCommand(connection) { CommandText = commandText }) { result = command.ExecuteNonQuery(); } connection.Close(); } return(result); }
/// <summary> /// /// </summary> /// <param name="connectionString"></param> /// <param name="commandText"></param> /// <returns></returns> public static object ExecuteScalar(string connectionString, string commandText) { object result; using (var connection = new MonetDbConnection(connectionString)) { connection.Open(); using (var command = new MonetDbCommand(connection) { CommandText = commandText }) { result = command.ExecuteScalar(); } connection.Close(); } return(result); }
/// <summary> /// /// </summary> /// <param name="connectionString"></param> /// <param name="commandText"></param> /// <returns></returns> public static DataSet ExecuteDataSet(string connectionString, string commandText) { DataSet ds; using (var connection = new MonetDbConnection(connectionString)) { connection.Open(); using (var command = new MonetDbCommand(connection) { CommandText = commandText }) { using (var reader = command.ExecuteReader()) { ds = reader.ToDateSet(); } } connection.Close(); } return(ds); }