Esempio n. 1
0
        public static DataSet getDataSet(string[] inSelectSQL, string inConString)
        {
            OleDbConnection connection1 = new OleDbConnection(inConString);
            DataSet         set1        = new DataSet();

            EmedDB.SQLRowIndex = 0;
            try
            {
                connection1.Open();
                for (int num1 = 0; num1 < inSelectSQL.Length; num1++)
                {
                    EmedDB.SQLRowIndex = num1;
                    new OleDbDataAdapter(inSelectSQL[num1], connection1).Fill(set1, "uncnet" + num1.ToString());
                }
                connection1.Close();
            }
            catch (Exception exception1)
            {
                EmedDB.SaveErrorToLog(exception1.Message, inSelectSQL[EmedDB.SQLRowIndex]);
            }
            finally
            {
                connection1.Dispose();
                OleDbConnection.ReleaseObjectPool();
                GC.Collect();
            }
            return(set1);
        }
Esempio n. 2
0
        public static bool TestConnection(string inConntionString)
        {
            bool            flag1;
            OleDbConnection connection1 = new OleDbConnection(inConntionString);

            try
            {
                connection1.Open();
                if (connection1.State == ConnectionState.Open)
                {
                    connection1.Close();
                    OleDbConnection.ReleaseObjectPool();
                    GC.Collect();
                    return(true);
                }
                flag1 = false;
            }
            catch (Exception exception1)
            {
                EmedDB.SaveErrorToLog(exception1.Message, "TestConnection");
                flag1 = false;
            }
            finally
            {
                connection1.Dispose();
                OleDbConnection.ReleaseObjectPool();
            }
            return(flag1);
        }
Esempio n. 3
0
        public static bool Transaction(string[] inSQL, string inConString)
        {
            if (inSQL.Length < 1)
            {
                return(true);
            }
            bool flag1 = false;

            using (OleDbConnection connection1 = new OleDbConnection(inConString))
            {
                try
                {
                    connection1.Open();
                    OleDbTransaction transaction1 = connection1.BeginTransaction(IsolationLevel.ReadCommitted);

                    try
                    {
                        for (int num1 = 0; num1 < inSQL.Length; num1++)
                        {
                            EmedDB.SQLRowIndex = num1;
                            EmedDB.DBErrorSQL  = inSQL[num1];
                            if (inSQL[num1].CompareTo("") > 0)
                            {
                                OleDbCommand command1 = new OleDbCommand();
                                command1.Connection  = connection1;
                                command1.CommandText = inSQL[num1];
                                command1.Transaction = transaction1;
                                command1.ExecuteNonQuery();
                            }
                        }
                        transaction1.Commit();
                        flag1 = true;
                    }
                    catch (Exception exception1)
                    {
                        transaction1.Rollback();
                        flag1 = false;
                        EmedDB.SaveErrorToLog(exception1.Message, EmedDB.DBErrorSQL);
                    }
                    connection1.Close();
                }
                catch
                {
                    flag1 = false;
                }
                finally
                {
                    connection1.Dispose();
                    OleDbConnection.ReleaseObjectPool();
                    GC.Collect();
                }
            }
            return(flag1);
        }
Esempio n. 4
0
        private static string GetPurchaseCode()
        {
            string text1 = "select iif( max(mid(purchase_code,10,8)) is null, '00000001', max(mid(purchase_code,10,8)) + 1 ) from gpo_purchase";
            string text2 = EmedDB.getScalar(text1);

            if ((text2 != null) && (text2 != ""))
            {
                return(int.Parse(text2).ToString("00000000"));
            }
            return("00000001");
        }
Esempio n. 5
0
        public static string getScalar(string inSelectSQL, string inConString)
        {
            if (inSelectSQL.CompareTo("") == 0)
            {
                return(null);
            }
            string          text1       = null;
            OleDbConnection connection1 = new OleDbConnection(inConString);

            try
            {
                connection1.Open();
                OleDbCommand command1 = new OleDbCommand(inSelectSQL, connection1);
                try
                {
                    object obj1 = command1.ExecuteScalar();
                    if (obj1 == null)
                    {
                        text1 = null;
                    }
                    else
                    {
                        text1 = obj1.ToString();
                    }
                }
                catch (Exception exception1)
                {
                    EmedDB.SaveErrorToLog(exception1.Message, inSelectSQL);
                    text1 = null;
                }
                finally
                {
                    command1.Dispose();
                }
                connection1.Close();
            }
            catch (Exception exception2)
            {
                EmedDB.SaveErrorToLog(exception2.Message, inSelectSQL);
            }
            finally
            {
                connection1.Dispose();
                OleDbConnection.ReleaseObjectPool();
                GC.Collect();
            }
            return(text1);
        }
Esempio n. 6
0
        /// <summary>
        /// 批量执行SQL
        /// </summary>
        /// <param name="inSQL">源SQL</param>
        /// <returns></returns>
        public static bool ExcuteSql(string[] inSQL)
        {
            bool            flag1       = true;
            OleDbConnection connection1 = new OleDbConnection(EmedDB.connStr);

            try
            {
                connection1.Open();
                OleDbCommand command1 = new OleDbCommand();
                for (int num1 = 0; num1 < inSQL.Length; num1++)
                {
                    if (inSQL[num1].Trim().CompareTo("") != 0)
                    {
                        command1 = new OleDbCommand(inSQL[num1], connection1);
                        try
                        {
                            command1.ExecuteNonQuery();
                        }
                        catch (Exception exception1)
                        {
                            string text1 = DateTime.Now.ToString() + "\t" + exception1.Message + "\t" + inSQL[num1];
                            EmedDB.SaveErrorToLog(text1, inSQL[num1]);
                            flag1 = false;
                        }
                    }
                }
                command1.Dispose();
                connection1.Close();
            }
            catch (Exception exception2)
            {
                EmedDB.SaveErrorToLog(exception2.Message, "Some sql exectue has error");
                flag1 = false;
            }
            finally
            {
                connection1.Dispose();
                OleDbConnection.ReleaseObjectPool();
                GC.Collect();
            }
            return(flag1);
        }
Esempio n. 7
0
        /// <summary>
        /// 单条执行SQL
        /// </summary>
        /// <param name="inSQL"></param>
        /// <returns></returns>
        public static bool ExcuteSql(string inSQL)
        {
            bool            flag1       = false;
            OleDbConnection connection1 = new OleDbConnection(EmedDB.connStr);

            try
            {
                connection1.Open();
                OleDbCommand command1 = new OleDbCommand(inSQL, connection1);
                try
                {
                    if (command1.ExecuteNonQuery() > -1)
                    {
                        flag1 = true;
                    }
                }
                catch (Exception exception1)
                {
                    string text1 = DateTime.Now.ToString() + "\t" + exception1.Message + "\t" + inSQL;
                    EmedDB.SaveErrorToLog(text1, inSQL);
                    flag1 = false;
                }
                finally
                {
                    command1.Dispose();
                }
                connection1.Close();
            }
            catch (Exception exception2)
            {
                EmedDB.SaveErrorToLog(exception2.Message, inSQL);
                flag1 = false;
            }
            finally
            {
                connection1.Dispose();
                OleDbConnection.ReleaseObjectPool();
                GC.Collect();
            }
            return(flag1);
        }
Esempio n. 8
0
        public static DataSet getDataSet(string inSelectSQL, string inConString)
        {
            OleDbConnection connection1 = new OleDbConnection(inConString);
            DataSet         set1        = new DataSet();

            try
            {
                connection1.Open();
                new OleDbDataAdapter(inSelectSQL, connection1).Fill(set1, "uncnet");
                connection1.Close();
            }
            catch (Exception exception1)
            {
                EmedDB.SaveErrorToLog(exception1.Message, inSelectSQL);
            }
            finally
            {
                connection1.Dispose();
                OleDbConnection.ReleaseObjectPool();
                GC.Collect();
            }
            return(set1);
        }
Esempio n. 9
0
 public static bool TestConnection()
 {
     return(EmedDB.TestConnection(EmedDB.connStr));
 }