Exemplo n.º 1
0
        /// <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;
        }
Exemplo n.º 2
0
        /// <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;
        }
Exemplo n.º 3
0
        /// <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;
        }
Exemplo n.º 4
0
        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;
        }
Exemplo n.º 5
0
        /// <summary>
        /// To get requested client database connection string from Client
        /// </summary>
        /// <param name="pClient">Client</param>
        /// <returns>returns Client database connection string</returns>
        //public  string GetClientDBConnString(Client pClient)
        //{
        //    //return "Data Source=" + pClient.DBIPAddress.Trim() + ";Initial Catalog=" + pClient.DatabaseName.Trim() + ";User ID=" + pClient.DBUID.Trim() + ";password="******";Max Pool Size=10;Min Pool Size=4;";
        //    return "Data Source=" + pClient.DBIPAddress.Trim() + ",1433;Network Library=DBMSSOCN" + ";Initial Catalog=" + pClient.DatabaseName.Trim() + ";User ID=" + pClient.DBUID.Trim() + ";password="******";";
        //}
        /// <summary>
        /// Returns DataSet result from Command
        /// </summary>
        /// <param name="pCommand">SQL Command</param>
        /// <param name="pConnString">Connection string</param>
        /// <returns>DataSet</returns>
        public DataSet SqlDataAdapter(SqlCommand pCommand, string pConnString)
        {
            DataSet dSet = null;
                pCommand.CommandType = CommandType.StoredProcedure;

                using (SqlConnection sqlconn = new SqlConnection(pConnString))
                {
                    pCommand.Connection = sqlconn;
                    dSet = SqlDataAdapter(pCommand);
                }

                AuditTrail objLog = new AuditTrail();
                objLog.LogSqlStatements(pCommand.CommandAsSql());

                return dSet;
        }
Exemplo n.º 6
0
        /// <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;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Execute Command for Single Update
        /// </summary>
        /// <param name="pCommand">SQL Command</param>
        /// <param name="pConnString">Connection string</param>
        /// <param name="pIsExecuted">boolean Is Executed</param>
        /// <returns>returns true if success</returns>
        public bool ExecuteNonQuery(SqlCommand pCommand, string pConnString, bool pIsExecuted)
        {
            pCommand.CommandType = CommandType.StoredProcedure;
                pIsExecuted = false;

                using (SqlConnection sqlcon = new SqlConnection(pConnString))
                {
                    sqlcon.Open();
                    pCommand.Connection = sqlcon;
                    pCommand.ExecuteNonQuery();
                }
                pIsExecuted = true;

                AuditTrail objLog = new AuditTrail();
                objLog.LogSqlStatements(pCommand.CommandAsSql());

                return pIsExecuted;
        }