示例#1
0
文件: Helper.cs 项目: weimingtom/pap2
        public static bool RemoveDbTable(string tblName, SqlConnection Conn)
        {
            bool bSuc = false;

            Conn.Open();
            try
            {
                string sql = "DROP TABLE " + tblName;

                /* remoting
                 * SqlCommand cmd = Conn.CreateCommand();
                 * cmd.CommandText = "DROP TABLE " + tblName;
                 * cmd.ExecuteNonQuery();
                 */
                if (Program.EnableRemoting)
                {
                    mDataTableProxy.OnlyReleaseTable(tblName);
                }
                Helper.ExecuteCommand(sql, Conn);

                bSuc = true;
            }
            catch (Exception ex)
            {
                string err = string.Format("在删除表 {0} 时发生错误。\r\n\r\n错误信息:{1}", tblName, ex.Message);
                MessageBox.Show(err);
                bSuc = false;
            }
            Conn.Close();
            return(bSuc);
        }