1.vs2005里面添加引用
2.添加using
3.创建数据库
public void CreatDB()
{
if (File.Exists("\\NandFlash\\CDZ3.sdf"))
File.Delete("\\NandFlash\\CDZ3.sdf");
try
{
//创建数据库
SqlCeEngine engine = new SqlCeEngine("Data Source = \\NandFlash\\CDZ3.sdf;password=cdz;encrypt database=TRUE");
engine.CreateDatabase();
engine.Dispose();
//连接远程数据库
/*
string rdaOleDbConnectString = "Provider=sqloledb.1;Data Source=192.168.1.17;
Initial Catalog=Northwind; User Id=sa;Password=sa";
SqlCeRemoteDataAccess rda = null;
rda = new SqlCeRemoteDataAccess();
rda.InternetUrl = "http://192.168.1.17/sqlce/sscesa20.dll";
rda.LocalConnectionString = @"Data Source=\My Documents\MobileService3.sdf;password=test";
rda.Pull("Region", "Select * from Region", rdaOleDbConnectString);
*/
//MessageBox.Show("ok!");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
4.效果