• 大小: 3.02KB
    文件类型: .cs
    金币: 1
    下载: 0 次
    发布日期: 2021-02-26
  • 语言: C#
  • 标签: sql  

资源简介

Sql CE Helper类源码下载

资源截图

代码片段和文件信息

class SqlCeHelper : IDisposable
    {
        private SqlCeConnection connection;
        private SqlCeCommand command;
        private const string connectionString = “Data Source=/DB/db.sdf“;

        #region Open/Close
        public void Open()
        {
            try
            {
                connection = new SqlCeConnection(connectionString);
                command = connection.CreateCommand();
                command.Connection = connection;
                command.CommandType = CommandType.Text;

                connection.Open();
            }
            catch (DataException e)
            {
                Console.WriteLine(e.Message);
            }
        }

        public void Close()
        {
            connection.Close();
            connection.Dispose();
        }

        public void Dispose()
        {
            connection.Close();
            connection.Dispose();
            command.Dispose();
        }
        #endreg

评论

共有 条评论