zoukankan      html  css  js  c++  java
  • Windws Mobile 6.5 Professional ADO.NET数据访问

    连接 SQL Server CE 数据库

    string sPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase.ToString());
                SqlCeConnection conn 
    = new SqlCeConnection("Data Source=" + sPath + "\\TestDB.sdf;Password ='123456'");
                SqlCeDataAdapter da 
    = new SqlCeDataAdapter("select * from testTb",conn);
                DataTable dt 
    = new DataTable();
                conn.Open();
                da.Fill(dt);
                conn.Close();
                
    if (dt != null && dt.Rows.Count > 0)
                {
                    MessageBox.Show(dt.Rows[
    0][1].ToString());
                }

     sPath是得到数据的绝对地址,将数据库sdf文件和可执行exe程序放在同一目录下即可

    如果是远程数据库则

    SqlConnection con = new SqlConnection("server=192.168.1.179;database=TestDB;uid=sa;pwd=123;");

    上面的服务器地址必须写真实的网络IP地址,不能为localhost或127.0.0.1

  • 相关阅读:
    MYSQL: 什么是MYSQLD Service
    100 logging模块
    099 hashlib和hmac模块
    098 json和pickle模块
    097 sys模块
    096 os模块
    095 random模块
    094 datetime模块
    093 time模块
    092 模块基础实战之ATM和购物车系统分文件处理
  • 原文地址:https://www.cnblogs.com/xh831213/p/1711037.html
Copyright © 2011-2022 走看看