C# Class SqlHelper, Orchard.Crawler

用于执行的 SQL 语句并返回结果
Mostra file Open project: cabbage89/Orchard.Crawler Class Usage Examples

Public Methods

Method Description
ExecuteDataset ( SqlConnection connection, CommandType commandType, string commandText ) : DataSet

Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection.

e.g.: DataSet ds = ExecuteDataset(conn, CommandType.StoredProcedure, "GetOrders");

ExecuteDataset ( SqlConnection connection, string spName ) : DataSet

Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.

This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: DataSet ds = ExecuteDataset(conn, "GetOrders", 24, 36);

ExecuteDataset ( SqlTransaction transaction, CommandType commandType, string commandText ) : DataSet

Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlTransaction.

e.g.: DataSet ds = ExecuteDataset(trans, CommandType.StoredProcedure, "GetOrders");

ExecuteDataset ( SqlTransaction transaction, string spName ) : DataSet

Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.

This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: DataSet ds = ExecuteDataset(trans, "GetOrders", 24, 36);

ExecuteDataset ( string connectionString, CommandType commandType, string commandText ) : DataSet

Execute a SqlCommand (that returns a resultset and takes no parameters) against the database specified in the connection string.

e.g.: DataSet ds = ExecuteDataset(connString, CommandType.StoredProcedure, "GetOrders");

ExecuteDataset ( string connectionString, string spName ) : DataSet

Execute a SqlCommand (that returns a resultset) against the database specified in the connection string using the provided parameters.

e.g.: DataSet ds = ExecuteDataset(connString, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));

ExecuteFillDataset ( DataSet dataSet, SqlConnection connection, CommandType commandType, string commandText ) : int

Execute a SqlCommand (that returns a resultset) against the specified SqlConnection using the provided parameters.

e.g.: ExecuteFillDataset(DataSet dataSet, conn, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));

ExecuteFillDataset ( DataSet dataSet, SqlTransaction transaction, CommandType commandType, string commandText ) : int

Execute a SqlCommand (that returns a resultset) against the specified SqlConnection and SqlTransaction using the provided parameters.

e.g.: ExecuteFillDataset(DataSet dataSet, conn, trans, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));

ExecuteFillDataset ( DataSet dataSet, string connectionString, CommandType commandType, string commandText ) : int

Execute a SqlCommand (that returns a resultset) against the database specified in the connection string using the provided parameters.

e.g.: ExecuteFillDataset(alias, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));

ExecuteFillDataset ( DataSet dataSet, string tableName, SqlConnection connection, CommandType commandType, string commandText ) : int

Execute a SqlCommand (that returns a resultset) against the specified SqlConnection using the provided parameters.

e.g.: ExecuteFillDataset(dataSet, tableName, conn, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));

ExecuteFillDataset ( DataSet dataSet, string tableName, SqlTransaction transaction, CommandType commandType, string commandText ) : int

Execute a SqlCommand (that returns a resultset) against the specified SqlConnection and SqlTransaction using the provided parameters.

e.g.: ExecuteFillDataset(dataSet, tableName, conn, trans, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));

ExecuteFillDataset ( DataSet dataSet, string tableName, string connectionString, CommandType commandType, string commandText ) : int
ExecuteNonQuery ( SqlConnection connection, CommandType commandType, string commandText ) : int

Execute a SqlCommand (that returns no resultset and takes no parameters) against the provided SqlConnection.

e.g.: int result = ExecuteNonQuery(conn, CommandType.StoredProcedure, "PublishOrders");

ExecuteNonQuery ( SqlConnection connection, SqlTransaction transaction, CommandType commandType, string commandText ) : int
ExecuteNonQuery ( SqlConnection connection, string spName ) : int

Execute a stored procedure via a SqlCommand (that returns no resultset) against the specified SqlConnection using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.

This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: int result = ExecuteNonQuery(conn, "PublishOrders", 24, 36);

ExecuteNonQuery ( SqlTransaction transaction, CommandType commandType, string commandText ) : int

Execute a SqlCommand (that returns no resultset and takes no parameters) against the provided SqlTransaction.

e.g.: int result = ExecuteNonQuery(trans, CommandType.StoredProcedure, "PublishOrders");

ExecuteNonQuery ( SqlTransaction transaction, string spName ) : int

Execute a stored procedure via a SqlCommand (that returns no resultset) against the specified SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.

This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: int result = ExecuteNonQuery(conn, trans, "PublishOrders", 24, 36);

ExecuteNonQuery ( SqlTransaction transaction, string connectionString, string spName ) : int

Execute a stored procedure via a SqlCommand (that returns no resultset) against the specified SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.

This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: int result = ExecuteNonQuery(conn, trans, "PublishOrders", 24, 36);

ExecuteNonQuery ( string connectionString, CommandType commandType, string commandText ) : int

Execute a SqlCommand (that returns no resultset and takes no parameters) against the database specified in the connection string.

e.g.: int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders");

ExecuteNonQuery ( string connectionString, string spName ) : int

Execute a SqlCommand (that returns no resultset) against the database specified in the connection string using the provided parameters

e.g.: int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));

ExecuteReader ( SqlConnection connection, CommandType commandType, string commandText ) : System.Data.SqlClient.SqlDataReader

Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection.

e.g.: SqlDataReader dr = ExecuteReader(conn, CommandType.StoredProcedure, "GetOrders");

ExecuteReader ( SqlConnection connection, SqlTransaction transaction, CommandType commandType, string commandText ) : System.Data.SqlClient.SqlDataReader
ExecuteReader ( SqlConnection connection, string spName ) : System.Data.SqlClient.SqlDataReader

Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.

This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: SqlDataReader dr = ExecuteReader(conn, "GetOrders", 24, 36);

ExecuteReader ( SqlTransaction transaction, CommandType commandType, string commandText ) : System.Data.SqlClient.SqlDataReader

Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlTransaction.

e.g.: SqlDataReader dr = ExecuteReader(trans, CommandType.StoredProcedure, "GetOrders");

ExecuteReader ( SqlTransaction transaction, string spName ) : System.Data.SqlClient.SqlDataReader

Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.

This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: SqlDataReader dr = ExecuteReader(trans, "GetOrders", 24, 36);

ExecuteReader ( string connectionString, CommandType commandType, string commandText ) : System.Data.SqlClient.SqlDataReader

Execute a SqlCommand (that returns a resultset and takes no parameters) against the database specified in the connection string.

e.g.: SqlDataReader dr = ExecuteReader(connString, CommandType.StoredProcedure, "GetOrders");

ExecuteReader ( string connectionString, string spName ) : SqlDataReader

Execute a stored procedure via a SqlCommand (that returns a resultset) against the database specified in the connection string using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.

This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: SqlDataReader dr = ExecuteReader(connString, "GetOrders", 24, 36);

ExecuteScalar ( SqlConnection connection, CommandType commandType, string commandText ) : object

Execute a SqlCommand (that returns a 1x1 resultset and takes no parameters) against the provided SqlConnection.

e.g.: int orderCount = (int)ExecuteScalar(conn, CommandType.StoredProcedure, "GetOrderCount");

ExecuteScalar ( SqlConnection connection, SqlTransaction transaction, CommandType commandType, string commandText ) : object
ExecuteScalar ( SqlConnection connection, string spName ) : object

Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the specified SqlConnection using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.

This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: int orderCount = (int)ExecuteScalar(conn, "GetOrderCount", 24, 36);

ExecuteScalar ( SqlTransaction transaction, CommandType commandType, string commandText ) : object

Execute a SqlCommand (that returns a 1x1 resultset and takes no parameters) against the provided SqlTransaction.

e.g.: int orderCount = (int)ExecuteScalar(trans, CommandType.StoredProcedure, "GetOrderCount");

ExecuteScalar ( SqlTransaction transaction, string spName ) : object

Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the specified SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.

This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: int orderCount = (int)ExecuteScalar(trans, "GetOrderCount", 24, 36);

ExecuteScalar ( SqlTransaction transaction, string connectionString, string spName ) : object

Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the specified SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.

This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: int orderCount = (int)ExecuteScalar(trans, "GetOrderCount", 24, 36);

ExecuteScalar ( string connectionString, CommandType commandType, string commandText ) : object

Execute a SqlCommand (that returns a 1x1 resultset and takes no parameters) against the database specified in the connection string.

e.g.: int orderCount = (int)ExecuteScalar(connString, CommandType.StoredProcedure, "GetOrderCount");

ExecuteScalar ( string connectionString, string spName ) : object

Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the database specified in the connection string using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.

This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: int orderCount = (int)ExecuteScalar(connString, "GetOrderCount", 24, 36);

ExecuteXmlReader ( SqlConnection connection, CommandType commandType, string commandText ) : XmlReader

Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection.

e.g.: XmlReader r = ExecuteXmlReader(conn, CommandType.StoredProcedure, "GetOrders");

ExecuteXmlReader ( SqlConnection connection, string spName ) : XmlReader

Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.

This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: XmlReader r = ExecuteXmlReader(conn, "GetOrders", 24, 36);

ExecuteXmlReader ( SqlTransaction transaction, CommandType commandType, string commandText ) : XmlReader

Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlTransaction.

e.g.: XmlReader r = ExecuteXmlReader(trans, CommandType.StoredProcedure, "GetOrders");

ExecuteXmlReader ( SqlTransaction transaction, string spName ) : XmlReader

Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.

This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: XmlReader r = ExecuteXmlReader(trans, "GetOrders", 24, 36);

Private Methods

Method Description
AssignParameterValues ( SqlParameter commandParameters, object parameterValues ) : void

This method assigns an array of values to an array of SqlParameters.

AttachParameters ( SqlCommand command, SqlParameter commandParameters ) : void

This method is used to attach array of SqlParameters to a SqlCommand. This method will assign a value of DbNull to any parameter with a direction of InputOutput and a value of null. This behavior will prevent default values from being used, but this will be the less common case than an intended pure output parameter (derived as InputOutput) where the user provided no input value.

ExecuteReader ( SqlConnection connection, SqlTransaction transaction, CommandType commandType, string commandText, SqlParameter commandParameters, SqlConnectionOwnership connectionOwnership ) : System.Data.SqlClient.SqlDataReader

Create and prepare a SqlCommand, and call ExecuteReader with the appropriate CommandBehavior.

If we created and opened the connection, we want the connection to be closed when the DataReader is closed. If the caller provided the connection, we want to leave it to them to manage.

PrepareCommand ( SqlCommand command, SqlConnection connection, SqlTransaction transaction, CommandType commandType, string commandText, SqlParameter commandParameters ) : void

This method opens (if necessary) and assigns a connection, transaction, command type and parameters to the provided command.

SqlHelper ( ) : System

Method Details

ExecuteDataset() public static method

Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection.
e.g.: DataSet ds = ExecuteDataset(conn, CommandType.StoredProcedure, "GetOrders");
public static ExecuteDataset ( SqlConnection connection, CommandType commandType, string commandText ) : DataSet
connection SqlConnection a valid SqlConnection
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command
return DataSet

ExecuteDataset() public static method

Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: DataSet ds = ExecuteDataset(conn, "GetOrders", 24, 36);
public static ExecuteDataset ( SqlConnection connection, string spName ) : DataSet
connection SqlConnection a valid SqlConnection
spName string the name of the stored procedure
return DataSet

ExecuteDataset() public static method

Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlTransaction.
e.g.: DataSet ds = ExecuteDataset(trans, CommandType.StoredProcedure, "GetOrders");
public static ExecuteDataset ( SqlTransaction transaction, CommandType commandType, string commandText ) : DataSet
transaction System.Data.SqlClient.SqlTransaction a valid SqlTransaction
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command
return DataSet

ExecuteDataset() public static method

Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: DataSet ds = ExecuteDataset(trans, "GetOrders", 24, 36);
public static ExecuteDataset ( SqlTransaction transaction, string spName ) : DataSet
transaction System.Data.SqlClient.SqlTransaction a valid SqlTransaction
spName string the name of the stored procedure
return DataSet

ExecuteDataset() public static method

Execute a SqlCommand (that returns a resultset and takes no parameters) against the database specified in the connection string.
e.g.: DataSet ds = ExecuteDataset(connString, CommandType.StoredProcedure, "GetOrders");
public static ExecuteDataset ( string connectionString, CommandType commandType, string commandText ) : DataSet
connectionString string a valid connection string for a SqlConnection
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command
return DataSet

ExecuteDataset() public static method

Execute a SqlCommand (that returns a resultset) against the database specified in the connection string using the provided parameters.
e.g.: DataSet ds = ExecuteDataset(connString, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
public static ExecuteDataset ( string connectionString, string spName ) : DataSet
connectionString string A valid connection string for a SqlConnection
spName string The stored procedure name
return DataSet

ExecuteFillDataset() public static method

Execute a SqlCommand (that returns a resultset) against the specified SqlConnection using the provided parameters.
e.g.: ExecuteFillDataset(DataSet dataSet, conn, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
public static ExecuteFillDataset ( DataSet dataSet, SqlConnection connection, CommandType commandType, string commandText ) : int
dataSet DataSet a valid dataSet to fill in
connection SqlConnection a valid SqlConnection
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command
return int

ExecuteFillDataset() public static method

Execute a SqlCommand (that returns a resultset) against the specified SqlConnection and SqlTransaction using the provided parameters.
e.g.: ExecuteFillDataset(DataSet dataSet, conn, trans, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
public static ExecuteFillDataset ( DataSet dataSet, SqlTransaction transaction, CommandType commandType, string commandText ) : int
dataSet DataSet a valid dataSet to fill in
transaction System.Data.SqlClient.SqlTransaction a valid SqlTransaction associated with the connection
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command
return int

ExecuteFillDataset() public static method

Execute a SqlCommand (that returns a resultset) against the database specified in the connection string using the provided parameters.
e.g.: ExecuteFillDataset(alias, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
public static ExecuteFillDataset ( DataSet dataSet, string connectionString, CommandType commandType, string commandText ) : int
dataSet DataSet a valid dataSet to fill in
connectionString string connection string
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command
return int

ExecuteFillDataset() public static method

Execute a SqlCommand (that returns a resultset) against the specified SqlConnection using the provided parameters.
e.g.: ExecuteFillDataset(dataSet, tableName, conn, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
public static ExecuteFillDataset ( DataSet dataSet, string tableName, SqlConnection connection, CommandType commandType, string commandText ) : int
dataSet DataSet a valid dataSet to fill in
tableName string a table name to fill in
connection SqlConnection a valid SqlConnection
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command
return int

ExecuteFillDataset() public static method

Execute a SqlCommand (that returns a resultset) against the specified SqlConnection and SqlTransaction using the provided parameters.
e.g.: ExecuteFillDataset(dataSet, tableName, conn, trans, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
public static ExecuteFillDataset ( DataSet dataSet, string tableName, SqlTransaction transaction, CommandType commandType, string commandText ) : int
dataSet DataSet a valid dataSet to fill in
tableName string a table name to fill in
transaction System.Data.SqlClient.SqlTransaction a valid SqlTransaction associated with the connection
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command
return int

ExecuteFillDataset() public static method

public static ExecuteFillDataset ( DataSet dataSet, string tableName, string connectionString, CommandType commandType, string commandText ) : int
dataSet DataSet
tableName string
connectionString string
commandType CommandType
commandText string
return int

ExecuteNonQuery() public static method

Execute a SqlCommand (that returns no resultset and takes no parameters) against the provided SqlConnection.
e.g.: int result = ExecuteNonQuery(conn, CommandType.StoredProcedure, "PublishOrders");
public static ExecuteNonQuery ( SqlConnection connection, CommandType commandType, string commandText ) : int
connection SqlConnection a valid SqlConnection
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command
return int

ExecuteNonQuery() public static method

public static ExecuteNonQuery ( SqlConnection connection, SqlTransaction transaction, CommandType commandType, string commandText ) : int
connection SqlConnection
transaction System.Data.SqlClient.SqlTransaction
commandType CommandType
commandText string
return int

ExecuteNonQuery() public static method

Execute a stored procedure via a SqlCommand (that returns no resultset) against the specified SqlConnection using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: int result = ExecuteNonQuery(conn, "PublishOrders", 24, 36);
public static ExecuteNonQuery ( SqlConnection connection, string spName ) : int
connection SqlConnection a valid SqlConnection
spName string the name of the stored procedure
return int

ExecuteNonQuery() public static method

Execute a SqlCommand (that returns no resultset and takes no parameters) against the provided SqlTransaction.
e.g.: int result = ExecuteNonQuery(trans, CommandType.StoredProcedure, "PublishOrders");
public static ExecuteNonQuery ( SqlTransaction transaction, CommandType commandType, string commandText ) : int
transaction System.Data.SqlClient.SqlTransaction a valid SqlTransaction
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command
return int

ExecuteNonQuery() public static method

Execute a stored procedure via a SqlCommand (that returns no resultset) against the specified SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: int result = ExecuteNonQuery(conn, trans, "PublishOrders", 24, 36);
public static ExecuteNonQuery ( SqlTransaction transaction, string spName ) : int
transaction System.Data.SqlClient.SqlTransaction a valid SqlTransaction
spName string the name of the stored procedure
return int

ExecuteNonQuery() public static method

Execute a stored procedure via a SqlCommand (that returns no resultset) against the specified SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: int result = ExecuteNonQuery(conn, trans, "PublishOrders", 24, 36);
public static ExecuteNonQuery ( SqlTransaction transaction, string connectionString, string spName ) : int
transaction System.Data.SqlClient.SqlTransaction a valid SqlTransaction
connectionString string
spName string the name of the stored procedure
return int

ExecuteNonQuery() public static method

Execute a SqlCommand (that returns no resultset and takes no parameters) against the database specified in the connection string.
e.g.: int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders");
public static ExecuteNonQuery ( string connectionString, CommandType commandType, string commandText ) : int
connectionString string a valid connection string for a SqlConnection
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command
return int

ExecuteNonQuery() public static method

Execute a SqlCommand (that returns no resultset) against the database specified in the connection string using the provided parameters
e.g.: int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));
public static ExecuteNonQuery ( string connectionString, string spName ) : int
connectionString string A valid connection string for a SqlConnection
spName string The stored procedure name
return int

ExecuteReader() public static method

Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection.
e.g.: SqlDataReader dr = ExecuteReader(conn, CommandType.StoredProcedure, "GetOrders");
public static ExecuteReader ( SqlConnection connection, CommandType commandType, string commandText ) : System.Data.SqlClient.SqlDataReader
connection SqlConnection a valid SqlConnection
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command
return System.Data.SqlClient.SqlDataReader

ExecuteReader() public static method

public static ExecuteReader ( SqlConnection connection, SqlTransaction transaction, CommandType commandType, string commandText ) : System.Data.SqlClient.SqlDataReader
connection SqlConnection
transaction System.Data.SqlClient.SqlTransaction
commandType CommandType
commandText string
return System.Data.SqlClient.SqlDataReader

ExecuteReader() public static method

Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: SqlDataReader dr = ExecuteReader(conn, "GetOrders", 24, 36);
public static ExecuteReader ( SqlConnection connection, string spName ) : System.Data.SqlClient.SqlDataReader
connection SqlConnection a valid SqlConnection
spName string the name of the stored procedure
return System.Data.SqlClient.SqlDataReader

ExecuteReader() public static method

Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlTransaction.
e.g.: SqlDataReader dr = ExecuteReader(trans, CommandType.StoredProcedure, "GetOrders");
public static ExecuteReader ( SqlTransaction transaction, CommandType commandType, string commandText ) : System.Data.SqlClient.SqlDataReader
transaction System.Data.SqlClient.SqlTransaction a valid SqlTransaction
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command
return System.Data.SqlClient.SqlDataReader

ExecuteReader() public static method

Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: SqlDataReader dr = ExecuteReader(trans, "GetOrders", 24, 36);
public static ExecuteReader ( SqlTransaction transaction, string spName ) : System.Data.SqlClient.SqlDataReader
transaction System.Data.SqlClient.SqlTransaction a valid SqlTransaction
spName string the name of the stored procedure
return System.Data.SqlClient.SqlDataReader

ExecuteReader() public static method

Execute a SqlCommand (that returns a resultset and takes no parameters) against the database specified in the connection string.
e.g.: SqlDataReader dr = ExecuteReader(connString, CommandType.StoredProcedure, "GetOrders");
public static ExecuteReader ( string connectionString, CommandType commandType, string commandText ) : System.Data.SqlClient.SqlDataReader
connectionString string a valid connection string for a SqlConnection
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command
return System.Data.SqlClient.SqlDataReader

ExecuteReader() public static method

Execute a stored procedure via a SqlCommand (that returns a resultset) against the database specified in the connection string using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: SqlDataReader dr = ExecuteReader(connString, "GetOrders", 24, 36);
public static ExecuteReader ( string connectionString, string spName ) : SqlDataReader
connectionString string a valid connection string for a SqlConnection
spName string the name of the stored procedure
return SqlDataReader

ExecuteScalar() public static method

Execute a SqlCommand (that returns a 1x1 resultset and takes no parameters) against the provided SqlConnection.
e.g.: int orderCount = (int)ExecuteScalar(conn, CommandType.StoredProcedure, "GetOrderCount");
public static ExecuteScalar ( SqlConnection connection, CommandType commandType, string commandText ) : object
connection SqlConnection a valid SqlConnection
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command
return object

ExecuteScalar() public static method

public static ExecuteScalar ( SqlConnection connection, SqlTransaction transaction, CommandType commandType, string commandText ) : object
connection SqlConnection
transaction SqlTransaction
commandType CommandType
commandText string
return object

ExecuteScalar() public static method

Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the specified SqlConnection using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: int orderCount = (int)ExecuteScalar(conn, "GetOrderCount", 24, 36);
public static ExecuteScalar ( SqlConnection connection, string spName ) : object
connection SqlConnection a valid SqlConnection
spName string the name of the stored procedure
return object

ExecuteScalar() public static method

Execute a SqlCommand (that returns a 1x1 resultset and takes no parameters) against the provided SqlTransaction.
e.g.: int orderCount = (int)ExecuteScalar(trans, CommandType.StoredProcedure, "GetOrderCount");
public static ExecuteScalar ( SqlTransaction transaction, CommandType commandType, string commandText ) : object
transaction SqlTransaction a valid SqlTransaction
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command
return object

ExecuteScalar() public static method

Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the specified SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: int orderCount = (int)ExecuteScalar(trans, "GetOrderCount", 24, 36);
public static ExecuteScalar ( SqlTransaction transaction, string spName ) : object
transaction SqlTransaction a valid SqlTransaction
spName string the name of the stored procedure
return object

ExecuteScalar() public static method

Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the specified SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: int orderCount = (int)ExecuteScalar(trans, "GetOrderCount", 24, 36);
public static ExecuteScalar ( SqlTransaction transaction, string connectionString, string spName ) : object
transaction SqlTransaction a valid SqlTransaction
connectionString string
spName string the name of the stored procedure
return object

ExecuteScalar() public static method

Execute a SqlCommand (that returns a 1x1 resultset and takes no parameters) against the database specified in the connection string.
e.g.: int orderCount = (int)ExecuteScalar(connString, CommandType.StoredProcedure, "GetOrderCount");
public static ExecuteScalar ( string connectionString, CommandType commandType, string commandText ) : object
connectionString string a valid connection string for a SqlConnection
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command
return object

ExecuteScalar() public static method

Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the database specified in the connection string using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: int orderCount = (int)ExecuteScalar(connString, "GetOrderCount", 24, 36);
public static ExecuteScalar ( string connectionString, string spName ) : object
connectionString string a valid connection string for a SqlConnection
spName string the name of the stored procedure
return object

ExecuteXmlReader() public static method

Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection.
e.g.: XmlReader r = ExecuteXmlReader(conn, CommandType.StoredProcedure, "GetOrders");
public static ExecuteXmlReader ( SqlConnection connection, CommandType commandType, string commandText ) : XmlReader
connection SqlConnection a valid SqlConnection
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command using "FOR XML AUTO"
return XmlReader

ExecuteXmlReader() public static method

Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: XmlReader r = ExecuteXmlReader(conn, "GetOrders", 24, 36);
public static ExecuteXmlReader ( SqlConnection connection, string spName ) : XmlReader
connection SqlConnection a valid SqlConnection
spName string the name of the stored procedure using "FOR XML AUTO"
return XmlReader

ExecuteXmlReader() public static method

Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlTransaction.
e.g.: XmlReader r = ExecuteXmlReader(trans, CommandType.StoredProcedure, "GetOrders");
public static ExecuteXmlReader ( SqlTransaction transaction, CommandType commandType, string commandText ) : XmlReader
transaction SqlTransaction a valid SqlTransaction
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command using "FOR XML AUTO"
return XmlReader

ExecuteXmlReader() public static method

Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
This method provides no access to output parameters or the stored procedure's return value parameter. e.g.: XmlReader r = ExecuteXmlReader(trans, "GetOrders", 24, 36);
public static ExecuteXmlReader ( SqlTransaction transaction, string spName ) : XmlReader
transaction SqlTransaction a valid SqlTransaction
spName string the name of the stored procedure
return XmlReader