数据库直接可在sqlce上建,然后添加相应的表和内容

解决方案 »

  1.   

    可以直接建,
    SqlCeConnection conn = new SqlCeConnection("Data Source = '" + System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + @"\Northwind.sdf'");
    这个是获得程序的相对路径,也可以用绝对路径。其他操作都一样了
      

  2.   

    能不能在详细一点,新手不太懂一些函数。System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + @"\Northwind.sdf'");
    我下载到设备上,出现的错误是 为处理的托管异常给个具体的例子
    比如我建了一个新数据库tester2,放到storage card下的sjk文件夹内,要连接这个数据库应该怎样写代码?
      

  3.   

    System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + @"\Northwind.sdf'");
    这个是取你当前程序的目录,如果你自己放在一个固定文件夹就用绝对路径了