C# Class Argentini.Halide.H3Reader

The H3Reader class provides a more powerful, flexible SQL reader class.
Inheritance: System.IDisposable
Show file Open project: argentini/Halide Class Usage Examples

Public Properties

Property Type Description
sqlCommandString string

Public Methods

Method Description
Close ( ) : void

Close a previously opened H3Reader object. You must close an opened H3Reader object when finished using it!

ColumnName ( int columnNumber ) : string

Get a column name by its number.

Dispose ( ) : void

Disposes the SmartReader.

GetBoolean ( string columnName ) : bool

Read a column value in as a boolean, by its column name.

GetColumnAllowNulls ( string columnName ) : bool

Does a specified column allow nulls? Returns false if no schema information is available.

GetColumnIsAutoIncrement ( string columnName ) : bool

Is a specified column an auto-incrementing field? Returns false if no schema information is available.

GetColumnIsIdentity ( string columnName ) : bool

Is a specified column an identity? Returns false if no schema information is available.

GetColumnIsKey ( string columnName ) : bool

Is the specified column a primary key? Returns false if no schema information is available.

GetColumnSize ( string columnName ) : int

Get the size (dimension) of the column, or zero if no schema information is available.

GetColumnSystemDataType ( string columnName ) : string

Return a column's equivalent system data type name (e.g. "String", "Int64", et al.). Returns an empty string if no schema information is available.

GetDataTypeName ( int columnIndex ) : string

Retrieve the SQL data type name of a specified column (e.g. "varchar", "int", "smallint", et al.).

GetDataTypeName ( string columnName ) : string

Retrieve the SQL data type name of a specified column (e.g. "varchar", "int", "smallint", et al.).

GetDate ( string columnName ) : string

Read a column value in as a string formatted as a date.

GetDateTime ( string columnName ) : System.DateTime

Read a column value in as a DateTime object.

GetDateTimeNullable ( string columnName ) : DateTime?

Read a column value in as a nullable DateTime object.

GetDecimal ( string columnName ) : decimal

Read a column value in as a decimal.

GetDouble ( string columnName ) : double

Read a column value in as a double.

GetFloat ( string columnName ) : float

Read a column value in as a float.

GetInt ( string columnName ) : int

Read a column value in as an integer.

GetInt32 ( string columnName ) : Int32

Read a column value in as an Int32.

GetInt32Nullable ( string columnName ) : Int32?

Read a column value in as a nullable Int32.

GetInt64 ( string columnName ) : System.Int64

Read a column value in as an Int64.

GetInt64Nullable ( string columnName ) : Int64?

Read a column value in as a nullable Int64.

GetLong ( string columnName ) : long

Read a column value in as a long.

GetMoney ( string columnName ) : string

Read a column value in as a string formatted as money.

GetPrimarykeyName ( ) : string

Get the primary key column name, or an empty string if schema is not available.

GetString ( int columnIndex ) : string

Read a column value in as a string, by its column number.

GetString ( string columnName ) : string

Read a column value in as a string, by its column name.

GetString ( string columnName, string defaultValue ) : string

Read a column value in as a string, by its column name.

GetStringNullable ( string columnName ) : String

Read a column value in as a string by its column name. Can return nulls.

GetStringOfMinutes ( string columnName ) : String

Gets a numeric field that represents minutes (ie 125) and converts it to an hour format (ie 2:05)

GetTime ( string columnName ) : string

Read a column value in as a string formatted as a time.

GetXMLResult ( ) : string

Read an XML result from a stored procedure. Used to bypass the 2,033 byte limit (multiple row) segmentation of XML results when simply requesting the column as a string. Reads in column 0 of all rows in the result set and appends them.

GetYesNo ( string columnName ) : string

Read a column value in and process as "Yes", "No", or "n/a" using the GetBoolean method.

H3Reader ( ) : System

Instantiate the class.

H3Reader ( String commandText, String filePath, String password, ConnectionStrings Connection_String ) : System

Instantiate the class for connecting to an external data source file.

H3Reader ( string commandText ) : System

Instantiate the class by passing a SQL command string.

H3Reader ( string commandText, bool getSchema ) : System

Instantiate the class by passing a SQL command string. Optionally enables getting schema information.

H3Reader ( string commandText, bool getSchema, string connectionName ) : System

Instantiate the class by passing a SQL command string, optionally enables getting schema information, pass a connection string name.

H3Reader ( string commandText, string connectionName ) : System

Instantiate the class by passing a SQL command string and connection string name.

H3Reader ( string commandText, string whereClause, string orderByClause, Int32 perPage, Int32 pageNum ) : System

Instantiate the class by passing a SQL command string, where clause, order by clause, rows per page, and page number, to receive only that page's rows. Only compatible with Microsoft SQL Server 2005 and later. Uses the default "Halide" connection string. If you insert [WHERECLAUSE] within your SELECT statement, you can force the passed where clause to be inserted for you; for advanced queries. The same holds true for [ORDERBY]. Remember NOT to include the "WHERE" or "ORDER BY" text in your passed arguments.

H3Reader ( string commandText, string whereClause, string orderByClause, Int32 perPage, Int32 pageNum, string useConnectionStringName ) : System

Instantiate the class by passing a SQL command string, where clause, order by clause, rows per page, and page number, to receive only that page's rows. Only compatible with Microsoft SQL Server 2005 and later. If you insert [WHERECLAUSE] within your SELECT statement, you can force the passed where clause to be inserted for you; for advanced queries. The same holds true for [ORDERBY]. Remember NOT to include the "WHERE" or "ORDER BY" text in your passed arguments.

IsNullOrEmpty ( string columnName ) : bool

Is a specified column value empty or null?

ListSchema ( ) : string

Retrieve the columns and their schema information as an ASCII text string for output.

NextResult ( ) : bool

Switch to the next result set; for use with SQL statements that return multiple (compound) recordsets.

Read ( ) : bool

Read the first (or next) row in the query.

ReadTable ( ) : DataTable

Create a dynamic DataTable object from a SQL data statement. One use for this method is to create a data source for other controls that want a DataTable, like 3rd party controls.

ReadTable ( System.Boolean addBlank ) : DataTable

Create a dynamic DataTable object from a SQL data statement. One use for this method is to create a data source for other controls that want a DataTable, like 3rd party controls.

this ( Int32 columnIndex ) : String

Shorthand for the GetString method. Returns a record as a string by column number.

this ( String columnName ) : String

Shorthand for the GetString method. Returns a record as a string by name.

Private Methods

Method Description
EnumValueOf ( String value, Type enumType ) : Object
ReadByPage ( string commandText, string WhereClause, string OrderByClause, Int32 PerPage, Int32 PageNum ) : void

Used by the constructor to read in a page of results.

StringValueOf ( Enum value ) : String

Method Details

Close() public method

Close a previously opened H3Reader object. You must close an opened H3Reader object when finished using it!
public Close ( ) : void
return void

ColumnName() public method

Get a column name by its number.
public ColumnName ( int columnNumber ) : string
columnNumber int Number of column to retrieve.
return string

Dispose() public method

Disposes the SmartReader.
public Dispose ( ) : void
return void

GetBoolean() public method

Read a column value in as a boolean, by its column name.
public GetBoolean ( string columnName ) : bool
columnName string Name of column to retrieve.
return bool

GetColumnAllowNulls() public method

Does a specified column allow nulls? Returns false if no schema information is available.
public GetColumnAllowNulls ( string columnName ) : bool
columnName string Name of the column.
return bool

GetColumnIsAutoIncrement() public method

Is a specified column an auto-incrementing field? Returns false if no schema information is available.
public GetColumnIsAutoIncrement ( string columnName ) : bool
columnName string Name of the column.
return bool

GetColumnIsIdentity() public method

Is a specified column an identity? Returns false if no schema information is available.
public GetColumnIsIdentity ( string columnName ) : bool
columnName string Name of the column.
return bool

GetColumnIsKey() public method

Is the specified column a primary key? Returns false if no schema information is available.
public GetColumnIsKey ( string columnName ) : bool
columnName string Name of the column.
return bool

GetColumnSize() public method

Get the size (dimension) of the column, or zero if no schema information is available.
public GetColumnSize ( string columnName ) : int
columnName string Name of the column.
return int

GetColumnSystemDataType() public method

Return a column's equivalent system data type name (e.g. "String", "Int64", et al.). Returns an empty string if no schema information is available.
public GetColumnSystemDataType ( string columnName ) : string
columnName string Name of the column.
return string

GetDataTypeName() public method

Retrieve the SQL data type name of a specified column (e.g. "varchar", "int", "smallint", et al.).
public GetDataTypeName ( int columnIndex ) : string
columnIndex int Number of the column.
return string

GetDataTypeName() public method

Retrieve the SQL data type name of a specified column (e.g. "varchar", "int", "smallint", et al.).
public GetDataTypeName ( string columnName ) : string
columnName string Name of the column.
return string

GetDate() public method

Read a column value in as a string formatted as a date.
public GetDate ( string columnName ) : string
columnName string Name of column to retrieve
return string

GetDateTime() public method

Read a column value in as a DateTime object.
public GetDateTime ( string columnName ) : System.DateTime
columnName string Name of column to retrieve.
return System.DateTime

GetDateTimeNullable() public method

Read a column value in as a nullable DateTime object.
public GetDateTimeNullable ( string columnName ) : DateTime?
columnName string Name of column to retrieve.
return DateTime?

GetDecimal() public method

Read a column value in as a decimal.
public GetDecimal ( string columnName ) : decimal
columnName string Name of column to retrieve.
return decimal

GetDouble() public method

Read a column value in as a double.
public GetDouble ( string columnName ) : double
columnName string Name of column to retrieve.
return double

GetFloat() public method

Read a column value in as a float.
public GetFloat ( string columnName ) : float
columnName string Name of column to retrieve.
return float

GetInt() public method

Read a column value in as an integer.
public GetInt ( string columnName ) : int
columnName string Name of column to retrieve.
return int

GetInt32() public method

Read a column value in as an Int32.
public GetInt32 ( string columnName ) : Int32
columnName string Name of column to retrieve.
return System.Int32

GetInt32Nullable() public method

Read a column value in as a nullable Int32.
public GetInt32Nullable ( string columnName ) : Int32?
columnName string Name of column to retrieve.
return Int32?

GetInt64() public method

Read a column value in as an Int64.
public GetInt64 ( string columnName ) : System.Int64
columnName string Name of column to retrieve.
return System.Int64

GetInt64Nullable() public method

Read a column value in as a nullable Int64.
public GetInt64Nullable ( string columnName ) : Int64?
columnName string Name of column to retrieve.
return Int64?

GetLong() public method

Read a column value in as a long.
public GetLong ( string columnName ) : long
columnName string Name of column to retrieve.
return long

GetMoney() public method

Read a column value in as a string formatted as money.
public GetMoney ( string columnName ) : string
columnName string Name of column to retrieve.
return string

GetPrimarykeyName() public method

Get the primary key column name, or an empty string if schema is not available.
public GetPrimarykeyName ( ) : string
return string

GetString() public method

Read a column value in as a string, by its column number.
public GetString ( int columnIndex ) : string
columnIndex int Number of column to retrieve.
return string

GetString() public method

Read a column value in as a string, by its column name.
public GetString ( string columnName ) : string
columnName string Name of column to retrieve.
return string

GetString() public method

Read a column value in as a string, by its column name.
public GetString ( string columnName, string defaultValue ) : string
columnName string Name of column to retrieve.
defaultValue string Default value to return if string is null or empty.
return string

GetStringNullable() public method

Read a column value in as a string by its column name. Can return nulls.
public GetStringNullable ( string columnName ) : String
columnName string Name of column to retrieve.
return String

GetStringOfMinutes() public method

Gets a numeric field that represents minutes (ie 125) and converts it to an hour format (ie 2:05)
public GetStringOfMinutes ( string columnName ) : String
columnName string Name of column to retrieve.
return String

GetTime() public method

Read a column value in as a string formatted as a time.
public GetTime ( string columnName ) : string
columnName string Name of column to retrieve.
return string

GetXMLResult() public method

Read an XML result from a stored procedure. Used to bypass the 2,033 byte limit (multiple row) segmentation of XML results when simply requesting the column as a string. Reads in column 0 of all rows in the result set and appends them.
public GetXMLResult ( ) : string
return string

GetYesNo() public method

Read a column value in and process as "Yes", "No", or "n/a" using the GetBoolean method.
public GetYesNo ( string columnName ) : string
columnName string Name of column to retrieve.
return string

H3Reader() public method

Instantiate the class.
public H3Reader ( ) : System
return System

H3Reader() public method

Instantiate the class for connecting to an external data source file.
public H3Reader ( String commandText, String filePath, String password, ConnectionStrings Connection_String ) : System
commandText String A SQL command to execute.
filePath String Web-style relative path to the file.
password String password for the file, if any, or a blank string.
Connection_String ConnectionStrings H3Reader.ConnectionString constant which defines the file type.
return System

H3Reader() public method

Instantiate the class by passing a SQL command string.
public H3Reader ( string commandText ) : System
commandText string A SQL command to execute.
return System

H3Reader() public method

Instantiate the class by passing a SQL command string. Optionally enables getting schema information.
public H3Reader ( string commandText, bool getSchema ) : System
commandText string A SQL command to execute.
getSchema bool Determines if schema information should also be retured, enabling various other methods and properties.
return System

H3Reader() public method

Instantiate the class by passing a SQL command string, optionally enables getting schema information, pass a connection string name.
public H3Reader ( string commandText, bool getSchema, string connectionName ) : System
commandText string A SQL command to execute.
getSchema bool Determines if schema information should also be retured, enabling various other methods and properties.
connectionName string Name of a connection string within the Web.Config file.
return System

H3Reader() public method

Instantiate the class by passing a SQL command string and connection string name.
public H3Reader ( string commandText, string connectionName ) : System
commandText string A SQL command to execute.
connectionName string Name of a connection string within the Web.Config file.
return System

H3Reader() public method

Instantiate the class by passing a SQL command string, where clause, order by clause, rows per page, and page number, to receive only that page's rows. Only compatible with Microsoft SQL Server 2005 and later. Uses the default "Halide" connection string. If you insert [WHERECLAUSE] within your SELECT statement, you can force the passed where clause to be inserted for you; for advanced queries. The same holds true for [ORDERBY]. Remember NOT to include the "WHERE" or "ORDER BY" text in your passed arguments.
public H3Reader ( string commandText, string whereClause, string orderByClause, Int32 perPage, Int32 pageNum ) : System
commandText string A SQL command to execute.
whereClause string Where clause without the "Where".
orderByClause string Order BY clause without the "order by".
perPage System.Int32 How many records per page?
pageNum System.Int32 Which page full of records to read.
return System

H3Reader() public method

Instantiate the class by passing a SQL command string, where clause, order by clause, rows per page, and page number, to receive only that page's rows. Only compatible with Microsoft SQL Server 2005 and later. If you insert [WHERECLAUSE] within your SELECT statement, you can force the passed where clause to be inserted for you; for advanced queries. The same holds true for [ORDERBY]. Remember NOT to include the "WHERE" or "ORDER BY" text in your passed arguments.
public H3Reader ( string commandText, string whereClause, string orderByClause, Int32 perPage, Int32 pageNum, string useConnectionStringName ) : System
commandText string A SQL command to execute.
whereClause string Where clause without the "Where".
orderByClause string Order BY clause without the "order by".
perPage System.Int32 How many records per page?
pageNum System.Int32 Which page full of records to read.
useConnectionStringName string Which connection string to use from within the Web.config file?
return System

IsNullOrEmpty() public method

Is a specified column value empty or null?
public IsNullOrEmpty ( string columnName ) : bool
columnName string Name of column to evaluate.
return bool

ListSchema() public method

Retrieve the columns and their schema information as an ASCII text string for output.
public ListSchema ( ) : string
return string

NextResult() public method

Switch to the next result set; for use with SQL statements that return multiple (compound) recordsets.
public NextResult ( ) : bool
return bool

Read() public method

Read the first (or next) row in the query.
public Read ( ) : bool
return bool

ReadTable() public method

Create a dynamic DataTable object from a SQL data statement. One use for this method is to create a data source for other controls that want a DataTable, like 3rd party controls.
public ReadTable ( ) : DataTable
return System.Data.DataTable

ReadTable() public method

Create a dynamic DataTable object from a SQL data statement. One use for this method is to create a data source for other controls that want a DataTable, like 3rd party controls.
public ReadTable ( System.Boolean addBlank ) : DataTable
addBlank System.Boolean Determine whether to add a blank row to the end or not.
return System.Data.DataTable

this() public method

Shorthand for the GetString method. Returns a record as a string by column number.
public this ( Int32 columnIndex ) : String
columnIndex System.Int32
return String

this() public method

Shorthand for the GetString method. Returns a record as a string by name.
public this ( String columnName ) : String
columnName String
return String

Property Details

sqlCommandString public property

SQL Command String.
public string sqlCommandString
return string