public void ExecuteTextToReaderWithIntParameters() { Framework.DataServices.CommonDatabase commonDatabase = new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName); Framework.DataServices.ParameterConfiguration parameterConfig = new Framework.DataServices.ParameterConfiguration(commonDatabase.GetProvider()); DbDataReader result = (DbDataReader)commonDatabase.ExecuteReader( CommandType.Text, "SELECT * FROM Users WHERE Children > @Children", false, CurrentUser, true, parameterConfig.Create("@Children", DbType.Int32, ParameterDirection.Input, 0)); }
public void ExecuteTextToNonQueryWithDataParameters() { Framework.DataServices.CommonDatabase commonDatabase = new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName); Framework.DataServices.ParameterConfiguration parameterConfig = new Framework.DataServices.ParameterConfiguration(commonDatabase.GetProvider()); int result = commonDatabase.ExecuteNonQuery( CommandType.Text, "SELECT * FROM Users WHERE BirthDate < @BirthDate", false, CurrentUser, parameterConfig.Create("@BirthDate", DbType.Date, ParameterDirection.Input, DateTime.Now)); }
public void ExecuteTextToScalarWithIntParameters() { Framework.DataServices.CommonDatabase commonDatabase = new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName); Framework.DataServices.ParameterConfiguration parameterConfig = new Framework.DataServices.ParameterConfiguration(commonDatabase.GetProvider()); object objResult = commonDatabase.ExecuteScalar( CommandType.Text, "SELECT count(*) FROM Users WHERE Children > @Children", false, CurrentUser, parameterConfig.Create("@Children", DbType.Int32, ParameterDirection.Input, 0)); }
public void FailedToExecuteTextToReaderInWrongFieldName() { Framework.DataServices.CommonDatabase commonDatabase = new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName); Framework.DataServices.ParameterConfiguration parameterConfig = new Framework.DataServices.ParameterConfiguration(commonDatabase.GetProvider()); DbDataReader result = (DbDataReader)commonDatabase.ExecuteReader( CommandType.Text, "SELECT * FROM Users_Fail " + " WHERE Children > @Children " + " AND BirthDateFail < @BirthDate ", false, CurrentUser, true, parameterConfig.Create("@Children", DbType.Int32, ParameterDirection.Input, 1), parameterConfig.Create("@BirthDate", DbType.Date, ParameterDirection.Input, DateTime.Now)); }
public void FailedToExecuteTextToScalarInWrongParameters() { Framework.DataServices.CommonDatabase commonDatabase = new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName); Framework.DataServices.ParameterConfiguration parameterConfig = new Framework.DataServices.ParameterConfiguration(commonDatabase.GetProvider()); object objResult = commonDatabase.ExecuteScalar( CommandType.Text, "SELECT count(*) FROM Users_Fail " + " WHERE Children > @Children " + " AND BirthDate < @BirthDate ", false, CurrentUser, parameterConfig.Create("@Children", DbType.Int32, ParameterDirection.Input, 1), parameterConfig.Create("@BirthDateFail", DbType.Date, ParameterDirection.Input, DateTime.Now)); }
public void ExecuteTextToDataSetWithIntAndDataParameters() { Framework.DataServices.CommonDatabase commonDatabase = new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName); Framework.DataServices.ParameterConfiguration parameterConfig = new Framework.DataServices.ParameterConfiguration(commonDatabase.GetProvider()); DataSet dsResult = commonDatabase.ExecuteDataSet( CommandType.Text, "SELECT * FROM Users " + " WHERE Children > @Children " + " AND BirthDate < @BirthDate ", false, CurrentUser, parameterConfig.Create("@Children", DbType.Int32, ParameterDirection.Input, 1), parameterConfig.Create("@BirthDate", DbType.Date, ParameterDirection.Input, DateTime.Now)); }