本文整理汇总了C#中System.Data.SqlClient.SqlCommand.CommandAsSql方法的典型用法代码示例。如果您正苦于以下问题:C# SqlCommand.CommandAsSql方法的具体用法?C# SqlCommand.CommandAsSql怎么用?C# SqlCommand.CommandAsSql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.SqlCommand
的用法示例。
在下文中一共展示了SqlCommand.CommandAsSql方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteMasterScalar
/// <summary>
/// Execute Command with Scalar method on Master Database
/// </summary>
/// <param name="pCommand">SQL Command</param>
/// <returns>Object</returns>
public Object ExecuteMasterScalar(SqlCommand pCommand)
{
pCommand.CommandType = CommandType.StoredProcedure;
Object objScalarReturn = null;
int iTry = 0;
using (SqlConnection sqlConnMaster = new SqlConnection(GetMasterDBConnString()))
{
pCommand.Connection = sqlConnMaster;
while (sqlConnMaster.State != ConnectionState.Open && iTry < itryCount)
{
if (sqlConnMaster.State != ConnectionState.Connecting)
{
sqlConnMaster.Open();
}
if (sqlConnMaster.State == ConnectionState.Open)
{
objScalarReturn = pCommand.ExecuteScalar();
break;
}
iTry++;
}
}
AuditTrail objLog = new AuditTrail();
objLog.LogSqlStatements(pCommand.CommandAsSql());
return objScalarReturn;
}
示例2: ExecuteMasterReader
/// <summary>
/// Execute Command on Master Database
/// </summary>
/// <param name="pCommand">SQL Command</param>
/// <returns>SqlDataReader object</returns>
public SqlDataReader ExecuteMasterReader(SqlCommand pCommand, bool pisConOpen)
{
pCommand.CommandType = CommandType.StoredProcedure;
SqlDataReader sqlreader = null;
if (!pisConOpen)
{
pCommand.Connection.Open();
}
sqlreader = pCommand.ExecuteReader();
AuditTrail objLog = new AuditTrail();
objLog.LogSqlStatements(pCommand.CommandAsSql());
return sqlreader;
}
示例3: ExecuteNonQuery
/// <summary>
/// Execute Command for Single Update
/// </summary>
/// <param name="pCommand">SQL Command</param>
/// <param name="pConnString">Connection string</param>
/// <returns>returns true if success</returns>
public int ExecuteNonQuery(SqlCommand pCommand, string pConnString)
{
int i = 0;
pCommand.CommandType = CommandType.StoredProcedure;
using (SqlConnection sqlcon = new SqlConnection(pConnString))
{
sqlcon.Open();
pCommand.Connection = sqlcon;
i = pCommand.ExecuteNonQuery();
}
AuditTrail objLog = new AuditTrail();
objLog.LogSqlStatements(pCommand.CommandAsSql());
return i;
}
示例4: SqlDataAdapter
public DataSet SqlDataAdapter(SqlCommand pCommand)
{
DataSet dSet = null;
pCommand.CommandType = CommandType.StoredProcedure;
dSet = new DataSet();
using (SqlDataAdapter dataAdaptor = new SqlDataAdapter(pCommand))
{
dataAdaptor.Fill(dSet);
}
AuditTrail objLog = new AuditTrail();
objLog.LogSqlStatements(pCommand.CommandAsSql());
return dSet;
}
示例5: ExecuteScalar
/// <summary>
/// Execute Command with Scalar method on Master Database
/// </summary>
/// <param name="pCommand">SQL Command</param>
/// <returns>Object</returns>
public Object ExecuteScalar(SqlCommand pCommand, bool pIsConnOpen)
{
pCommand.CommandType = CommandType.StoredProcedure;
Object objScalarReturn = null;
if (!pIsConnOpen)
{
pCommand.Connection.Open();
}
objScalarReturn = pCommand.ExecuteScalar();
AuditTrail objLog = new AuditTrail();
objLog.LogSqlStatements(pCommand.CommandAsSql());
return objScalarReturn;
}