Ejemplo n.º 1
0
        //Added for CSharp Station Report Wizard CR13
        internal static bool ExecuteSelect(string SqlStatement, bool ErrMsg,
                                           string table, string CallingClass, string CallingFunction,
                                           out SAConnection _conn, out SADataReader myDataReader, bool bLocalDB)
        {
            bool RetVal = true;

            myDataReader = null;
            _conn        = null;

            try
            {
                _conn = bLocalDB ? MainClass.GetConnection() : MainClass.GetMasterConnection();
                _conn.Open();
                RetVal = (ConnectionState.Open == _conn.State);

                if (RetVal)
                {
                    SACommand cmd = new SACommand(SqlStatement, _conn);
                    myDataReader = cmd.ExecuteReader();
                }
            }
            catch (Exception ex)
            {
                RetVal = false;
                if (ErrMsg)
                {
                    string err = String.Format(StringTable.GetString("DatabaseError"),
                                               table, ex.Message.ToString() + "(" + SqlStatement + ")");
                    ServiceMessages.InsertRec(MainClass.AppName, CallingClass, CallingFunction, err);
                }
            }

            return(RetVal);
        }
Ejemplo n.º 2
0
        //Added for CSharp Station Report Wizard CR13
        public static bool TestDBConnection(bool bLocalDB)
        {
            SAConnection _conn  = null;
            bool         RetVal = false;

            try
            {
                _conn = bLocalDB ? MainClass.GetConnection() : MainClass.GetMasterConnection();
                _conn.Open();
                RetVal = (ConnectionState.Open == _conn.State);
            }
            catch (Exception ex)
            {
                RetVal = false;
            }
            finally
            {
                if (_conn != null)
                {
                    _conn.Close();
                }
            }

            return(RetVal);
        }