sqlce基本语法

整理和总结一下SQLCE的用法
引用  System.Data.SqlServerCe
(1)数据库文件的创建
     SqlCeEngine eng = new SqlCeEngine("DataSource = " + 
         FileName);
     eng.CreateDatabase();
(2)初始化连接
    m_SqlCeConn = new SqlCeConnection("DataSource =" + m_LocalDbFile);
    m_SqlCeConn.Open();//关闭连接: m_SqlCeConn.Close();
(3)表是否存在的判断
"select table_name from information_schema.tables where table_name = "T_Test "
(4)创建表
@"
                        CREATE TABLE T_Test (PId int identity(1,1),
                          PCode int, F int, P ntext,
                          D datetime)"


(5)查询
     SqlCeDataAdapter adpt = 
        new SqlCeDataAdapter(sql, m_SqlCeConn);
     adpt.Fill(dsResult);


(6)执行
    SqlCeCommand cmd = new SqlCeCommand(sql, m_SqlCeConn);
    int effectRowNum = cmd.ExecuteNonQuery();
    if (effectRowNum  != 0)
        //成功
        
(7)SQLCE只支持简单的SQL语法

posted @ 2019-09-25 11:15  岳凯歌  阅读(731)  评论(0编辑  收藏  举报