本文整理汇总了C#中System.Data.SqlClient.SqlCommand.RunExecuteReader方法的典型用法代码示例。如果您正苦于以下问题:C# SqlCommand.RunExecuteReader方法的具体用法?C# SqlCommand.RunExecuteReader怎么用?C# SqlCommand.RunExecuteReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.SqlCommand
的用法示例。
在下文中一共展示了SqlCommand.RunExecuteReader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetServerTransactionLevel
private int GetServerTransactionLevel()
{
// This function is needed for those times when it is impossible to determine the server's
// transaction level, unless the user's arguments were parsed - which is something we don't want
// to do. An example when it is impossible to determine the level is after a rollback.
using (SqlCommand transactionLevelCommand = new SqlCommand("set @out = @@trancount", (SqlConnection)(_innerConnection.Owner)))
{
transactionLevelCommand.Transaction = Parent;
SqlParameter parameter = new SqlParameter("@out", SqlDbType.Int);
parameter.Direction = ParameterDirection.Output;
transactionLevelCommand.Parameters.Add(parameter);
transactionLevelCommand.RunExecuteReader(CommandBehavior.Default, RunBehavior.UntilDone, returnStream: false);
return (int)parameter.Value;
}
}
示例2: GetServerTransactionLevel
private int GetServerTransactionLevel()
{
using (SqlCommand command = new SqlCommand("set @out = @@trancount", (SqlConnection) this._innerConnection.Owner))
{
command.Transaction = this.Parent;
SqlParameter parameter = new SqlParameter("@out", SqlDbType.Int) {
Direction = ParameterDirection.Output
};
command.Parameters.Add(parameter);
command.RunExecuteReader(CommandBehavior.Default, RunBehavior.UntilDone, false, "GetServerTransactionLevel");
return (int) parameter.Value;
}
}