CommandType, _ ByVal commandText As String, _ ByVal ParamArray commandParameters() As SqlParameter) Execute* (ByVal connection As SqlConnection, _ ByVal spName As String, _ ByVal ParamArray parameterValues() As Object) Execute* (ByVal transaction As SqlTransaction, _ ByVal commandType As CommandType, _ ByVal commandText As String) Execute* (ByVal transaction As SqlTransaction, _ ByVal commandType As CommandType, _ ByVal commandText As String, _ ByVal ParamArray commandParameters() As SqlParameter) Execute* (ByVal transaction As SqlTransaction, _ ByVal spName As String, _ ByVal ParamArray parameterValues() As Object) [C#] Execute* (SqlConnection connection, CommandType commandType, string commandText) Execute* (SqlConnection connection, CommandType commandType, string commandText, params SqlParameter commandParameters) Execute* (SqlConnection connection, string spName, params object parameterValues) Execute* (SqlConnection connection, CommandType commandType, string commandText) Execute* (SqlConnection connection, CommandType commandType, string commandText, params SqlParameter commandParameters) Execute* (SqlConnection connection, string spName, params object parameterValues)
除这些重载以外,除 ExecuteXmlReader 之外的其他方法还提供了另一种重载:允许将连接信息作为连接字符串而不是连接对象来传递,如下面的方法签名所示:
[Visual Basic] Execute* (ByVal connectionString As String, _ ByVal commandType As CommandType, _ ByVal commandText As String) Execute* (ByVal connectionString As String, _ ByVal commandType As CommandType, _ ByVal commandText As String, _ ByVal ParamArray commandParameters() As SqlParameter) Execute* (ByVal connectionString As String, _ ByVal spName As String, _ ByVal ParamArray parameterValues() As Object) [C#] Execute* (string connectionString, CommandType commandType, string commandText) Execute* (string connectionString, CommandType commandType, string commandText, params SqlParameter commandParameters) Execute* (string connectionString, string spName, params object parameterValues)
注意: ExecuteXmlReader 不支持连接字符串,因为:与 SqlDataReader 对象不同,XmlReader 对象在 XmlReader 关闭时没有提供自动关闭连接的方法。如果客户端传递了连接字符串,那么当客户端完成对 XmlReader 的操作后,将无法关闭与 XmlReader 相关联的连接对象。
通过参考 Data Access Application Block 程序集并导入 Microsoft.ApplicationBlocks.Data 命名空间,您可以轻松编写使用任何一种 SqlHelper 类方法的代码,如下面的代码示例所示:
[Visual Basic] Imports Microso