当前位置: 首页>>代码示例>>C#>>正文


C# SqlCommand.CommandAsSql方法代码示例

本文整理汇总了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;
        }
开发者ID:stiqraschool,项目名称:eSchool,代码行数:33,代码来源:SQLObject.cs

示例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;
        }
开发者ID:stiqraschool,项目名称:eSchool,代码行数:20,代码来源:SQLObject.cs

示例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;
        }
开发者ID:stiqraschool,项目名称:eSchool,代码行数:23,代码来源:SQLObject.cs

示例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;
        }
开发者ID:stiqraschool,项目名称:eSchool,代码行数:15,代码来源:SQLObject.cs

示例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;
        }
开发者ID:stiqraschool,项目名称:eSchool,代码行数:21,代码来源:SQLObject.cs


注:本文中的System.Data.SqlClient.SqlCommand.CommandAsSql方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。