Access 97'数据库上的表创建 - 如何启用Unicode压缩

时间:2011-12-20 12:41:31

标签: c# ms-access

我正在使用以下命令在现有的Access 97'数据库中创建一个表:

OleDbCommand cmd_createPlaylistNames2 = new OleDbCommand("CREATE TABLE PlaylistNames2 ([Anagnorisi] long, [PlaylistName] TEXT(50) WITH COMPRESSION, [PlaylistMaker] TEXT(50) WITH COMPRESSION," +
            " [Duration] TEXT(50) WITH COMPRESSION, [Comments] TEXT(50), [FromAutomation] BIT, Primary Key (Anagnorisi))", con);

然后我用数据集中的数据填充表格。当我用Office打开数据库时,我设置为WITH COMPRESSION的字段将Unicode Compression属性设置为否。 任何想法为什么会发生这种情况?

编辑:

没关系,我已经使用DAO将字段设置为Unicode压缩。

dao.DBEngine dbeng = new dao.DBEngine();
dao.Workspace wrkspc = dbeng.CreateWorkspace("", "admin", "", dao.WorkspaceTypeEnum.dbUseJet);
dao.Database db = wrkspc.OpenDatabase("C:\\Users\\user\\Desktop\\Merge2\\playlists.MDB", false, false, "");
dao.TableDef tabledef = db.TableDefs["PlaylistNames"];
dao.Field name = tabledef.Fields["PlaylistName"];
dao.Field maker = tabledef.Fields["PlaylistMaker"];
dao.Field duration = tabledef.Fields["Duration"];
dao.Field comments = tabledef.Fields["Comments"];

dao.Property propName = name.CreateProperty("UnicodeCompression", 1, -1, false);
name.Properties.Append(propName);

dao.Property propMaker = maker.CreateProperty("UnicodeCompression", 1, -1, false);
maker.Properties.Append(propMaker);

dao.Property propDuration = duration.CreateProperty("UnicodeCompression", 1, -1, false);
duration.Properties.Append(propDuration);

dao.Property propComments = comments.CreateProperty("UnicodeCompression", 1, -1, false);
comments.Properties.Append(propComments);

wrkspc.Close();

1 个答案:

答案 0 :(得分:1)

Access 97使用Jet 3.5; Jet 4.0中引入了16位文本存储。因此,无论UnicodeCompression标志的值如何,如果数据库版本小于4,您将发现文件使用的是单字节字符。

相关问题