创建Access数据库(文件名为:Data.MDF 密码为:123456) String connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=123456;Data Source=c://Data.MDF;"; ADOX.CatalogClass CreateADOX = new CatalogClass(); CreateADOX.Create(connectionString);
第一: String connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=123456;Data Source=c://Data.MDF;"; IDataLayer dataLayer = XpoDefault.GetDataLayer(connectionString, AutoCreateOption.DatabaseAndSchema); Session retSession = new Session(dataLayer); if (!retSession.IsConnected) { retSession.Connect(); }
第二: string connectionString = MSSqlConnectionProvider.GetConnectionString(开发库配置.Host, 开发库配置.UserName, 开发库配置.PassWord, 开发库配置.Database); IDataLayer dataLayer = XpoDefault.GetDataLayer(connectionString, AutoCreateOption.DatabaseAndSchema); XpoDefault.DataLayer = dataLayer; Session retSession = XpoDefault.Session; if (!retSession.IsConnected) { retSession.Connect(); }
第三: String connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=123456;Data Source=c://Data.MDF;"; IDataLayer dataLayer = XpoDefault.GetDataLayer(connectionString, AutoCreateOption.DatabaseAndSchema); XpoDefault.DataLayer = dataLayer; Session retSession = XpoDefault.Session; if (!retSession.IsConnected) { retSession.Connect(); }
|