万能吗?

来源:互联网 发布:环境专业数据网站 编辑:程序博客网 时间:2024/06/11 15:14

    class SQLHelper
    {

        static string p = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
        public static int ExcuteSQL(string sql, string load)
        {
            string ConStr = "Data Source=" + p + load;
            SqlCeConnection conn = new SqlCeConnection(ConStr);

            int count = 0;
            try
            {
                conn.Open();
                SqlCeCommand cmd = new SqlCeCommand(sql, conn);
                count = cmd.ExecuteNonQuery();
                cmd.Dispose();
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);

            }
            finally
            {
                conn.Close();
            }
            return count;
        }//增删改

        public static DataTable GetTable(string sql, string load)
        {
            string ConStr = "Data Source=" + p + load;
            SqlCeConnection conn = new SqlCeConnection(ConStr);

            DataTable dt = new DataTable();
            try
            {
                SqlCeDataAdapter sda = new SqlCeDataAdapter(sql, conn);
                sda.Fill(dt);
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
            return dt;

        }//查

 

 

求教!!!!!!!!!!!

这段代码可以万能使用吗?

这个是移动开发平台的!!!!!!

原创粉丝点击