예제 #1
0
        public void DBAdapter(object SQL)
        {
            MyInvoke         mi      = new MyInvoke(miCMDSQL);
            MyInvoke         end     = new MyInvoke(miEND);
            MainForm         f1      = new MainForm();
            UpdateItemInfo   uii     = new UpdateItemInfo(f1.GetItemInfo);
            DataSet          ds      = new DataSet();
            MySqlConnection  Conn    = new MySqlConnection(MainForm.GetConnStr());
            MySqlCommand     setname = new MySqlCommand("set names 'gbk';", Conn);
            MySqlDataAdapter adp     = new MySqlDataAdapter(SQL.ToString(), Conn);

            try
            {
                Conn.Open();
                setname.ExecuteNonQuery();
                setname.Dispose();
                adp.Fill(ds);
                this.Invoke(uii, ds);
                this.Invoke(mi, "执行成功!");
                Thread.Sleep(1000);
                this.Invoke(end, "true");
            }
            catch (Exception err)
            {
                ItemInfo.Stat = false;
                this.Invoke(mi, "执行失败!");
                this.Invoke(end, err.Message);
            }
        }
예제 #2
0
 public void DBAdapter(object SQL)
 {
     MyInvoke mi = new MyInvoke(miCMDSQL);
     MyInvoke end = new MyInvoke(miEND);
     MainForm f1 = new MainForm();
     UpdateItemInfo uii = new UpdateItemInfo(f1.GetItemInfo);
     DataSet ds = new DataSet();
     MySqlConnection Conn = new MySqlConnection(MainForm.GetConnStr());
     MySqlCommand setname = new MySqlCommand("set names 'gbk';", Conn);
     MySqlDataAdapter adp = new MySqlDataAdapter(SQL.ToString(), Conn);
     try
     {
         Conn.Open();
         setname.ExecuteNonQuery();
         setname.Dispose();
         adp.Fill(ds);
         this.Invoke(uii, ds);
         this.Invoke(mi, "执行成功!");
         Thread.Sleep(1000);
         this.Invoke(end, "true");
     }
     catch (Exception err)
     {
         ItemInfo.Stat = false;
         this.Invoke(mi, "执行失败!");
         this.Invoke(end, err.Message);
     }
 }