/// <summary> /// 创建新的信息数据库 /// </summary> private void CreatDb() { string con = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=dac.accdb"; ADOX.Catalog catalog = new Catalog(); catalog.Create(con);//创建新的数据库 catalog.ActiveConnection(); ADODB.Connection connection = new ADODB.Connection(); connection.Open(con, null, null, -1); //新建主体信息数据表 ADOX.Table table = new Table(); table.Name = "主体信息表"; ADOX.Column subjectName = new Column();//主体名称 subjectName.Name = "主体名称"; ADOX.Column pwd = new Column();//主体登录密码 pwd.Name = "密码"; ADOX.Column SubjectRegisterTime = new Column();//主体登录密码 SubjectRegisterTime.Name = "注册时间"; table.Columns.Append(subjectName);//将列添加到表中 table.Columns.Append(pwd); table.Columns.Append(SubjectRegisterTime); catalog.Tables.Append(table); //新建角色信息数据表 table = new Table(); table.Name = "角色信息表"; ADOX.Column RoleName = new Column();//角色名称 RoleName.Name = "角色名称"; ADOX.Column RoleRegisterTime= new Column();//角色注册时间 RoleRegisterTime.Name = "创建时间"; table.Columns.Append(RoleName);//将列添加到表中 table.Columns.Append(RoleRegisterTime); catalog.Tables.Append(table); //新建角互斥色信息数据表 table = new Table(); table.Name = "互斥角色信息表"; ADOX.Column ExclusionRoleName = new Column();//角色名称 ExclusionRoleName.Name = "角色1名称"; ADOX.Column ExclusionRoleName1 = new Column();//角色名称 ExclusionRoleName1.Name = "角色2名称"; table.Columns.Append(ExclusionRoleName);//将列添加到表中 table.Columns.Append(ExclusionRoleName1); catalog.Tables.Append(table); //新建角色关系信息数据表 table = new Table(); table.Name = "角色关系信息表"; ADOX.Column FatherRoleName = new Column();//角色名称 FatherRoleName.Name = "父角色名称"; ADOX.Column ChildRoleName = new Column();//角色名称 ChildRoleName.Name = "子角色名称"; table.Columns.Append(FatherRoleName);//将列添加到表中 table.Columns.Append(ChildRoleName); catalog.Tables.Append(table); //新建权限信息表 table = new Table(); table.Name = "权限信息表"; ADOX.Column PermissionName = new Column();//权限名称 PermissionName.Name = "权限名称"; ADOX.Column PermissionRegisterTime = new Column();//权限创建注册时间 PermissionRegisterTime.Name = "创建时间"; table.Columns.Append(PermissionName);//将列添加到表中 table.Columns.Append(PermissionRegisterTime); catalog.Tables.Append(table); //新建用户角色指派信息表 table = new Table(); table.Name = "用户-角色指派信息表"; ADOX.Column UserName = new Column();//用户名称 UserName.Name = "用户名称"; RoleName = new Column();//角色名称 RoleName.Name = "角色名称"; table.Columns.Append(UserName);//将列添加到表中 table.Columns.Append(RoleName); catalog.Tables.Append(table); //新建角色到权限的指派信息表 table = new Table(); table.Name = "角色-权限指派信息表"; RoleName = new Column();//角色名称 RoleName.Name = "角色名称"; PermissionName = new Column();//权限名称 PermissionName.Name = "权限名称"; table.Columns.Append(RoleName); table.Columns.Append(PermissionName); catalog.Tables.Append(table); //新建注册管理表 table = new Table(); table.Name = "注册管理表"; ADOX.Column subject_Name1 = new Column();//客体名称 subject_Name1.Name = "主体名称"; ADOX.Column time = new Column();//客体名称 time.Name = "注册时间"; ADOX.Column pwd1 = new Column();//客体名称 pwd1.Name = "密码"; table.Columns.Append(subject_Name1); table.Columns.Append(time); table.Columns.Append(pwd1); catalog.Tables.Append(table); connection.Close();//关闭连接 }
/// <summary> /// 创建新的信息数据库 /// </summary> private void CreatDb() { string con = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=dac.accdb"; ADOX.Catalog catalog = new Catalog(); catalog.Create(con);//创建新的数据库 catalog.ActiveConnection(); ADODB.Connection connection = new ADODB.Connection(); connection.Open(con, null, null, -1); //新建主体信息数据表 ADOX.Table table = new Table(); table.Name = "主体信息表"; ADOX.Column subjectName = new Column(); //主体名称 subjectName.Name = "主体名称"; ADOX.Column pwd = new Column(); //主体登录密码 pwd.Name = "密码"; ADOX.Column SubjectRegisterTime = new Column(); //主体登录密码 SubjectRegisterTime.Name = "注册时间"; table.Columns.Append(subjectName);//将列添加到表中 table.Columns.Append(pwd); table.Columns.Append(SubjectRegisterTime); catalog.Tables.Append(table); //新建角色信息数据表 table = new Table(); table.Name = "角色信息表"; ADOX.Column RoleName = new Column();//角色名称 RoleName.Name = "角色名称"; ADOX.Column RoleRegisterTime = new Column();//角色注册时间 RoleRegisterTime.Name = "创建时间"; table.Columns.Append(RoleName);//将列添加到表中 table.Columns.Append(RoleRegisterTime); catalog.Tables.Append(table); //新建角互斥色信息数据表 table = new Table(); table.Name = "互斥角色信息表"; ADOX.Column ExclusionRoleName = new Column(); //角色名称 ExclusionRoleName.Name = "角色1名称"; ADOX.Column ExclusionRoleName1 = new Column(); //角色名称 ExclusionRoleName1.Name = "角色2名称"; table.Columns.Append(ExclusionRoleName);//将列添加到表中 table.Columns.Append(ExclusionRoleName1); catalog.Tables.Append(table); //新建角色关系信息数据表 table = new Table(); table.Name = "角色关系信息表"; ADOX.Column FatherRoleName = new Column(); //角色名称 FatherRoleName.Name = "父角色名称"; ADOX.Column ChildRoleName = new Column(); //角色名称 ChildRoleName.Name = "子角色名称"; table.Columns.Append(FatherRoleName); //将列添加到表中 table.Columns.Append(ChildRoleName); catalog.Tables.Append(table); //新建权限信息表 table = new Table(); table.Name = "权限信息表"; ADOX.Column PermissionName = new Column(); //权限名称 PermissionName.Name = "权限名称"; ADOX.Column PermissionRegisterTime = new Column(); //权限创建注册时间 PermissionRegisterTime.Name = "创建时间"; table.Columns.Append(PermissionName);//将列添加到表中 table.Columns.Append(PermissionRegisterTime); catalog.Tables.Append(table); //新建用户角色指派信息表 table = new Table(); table.Name = "用户-角色指派信息表"; ADOX.Column UserName = new Column(); //用户名称 UserName.Name = "用户名称"; RoleName = new Column(); //角色名称 RoleName.Name = "角色名称"; table.Columns.Append(UserName);//将列添加到表中 table.Columns.Append(RoleName); catalog.Tables.Append(table); //新建角色到权限的指派信息表 table = new Table(); table.Name = "角色-权限指派信息表"; RoleName = new Column(); //角色名称 RoleName.Name = "角色名称"; PermissionName = new Column(); //权限名称 PermissionName.Name = "权限名称"; table.Columns.Append(RoleName); table.Columns.Append(PermissionName); catalog.Tables.Append(table); //新建注册管理表 table = new Table(); table.Name = "注册管理表"; ADOX.Column subject_Name1 = new Column(); //客体名称 subject_Name1.Name = "主体名称"; ADOX.Column time = new Column(); //客体名称 time.Name = "注册时间"; ADOX.Column pwd1 = new Column(); //客体名称 pwd1.Name = "密码"; table.Columns.Append(subject_Name1); table.Columns.Append(time); table.Columns.Append(pwd1); catalog.Tables.Append(table); connection.Close();//关闭连接 }