mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-10-27 02:51:17 +00:00
Fix the index creation failure
This commit is contained in:
parent
ece369f8f0
commit
3e4b6a73b5
|
|
@ -105,22 +105,23 @@ namespace WelsonJS.Launcher
|
||||||
Api.JetAddColumn(_session, tableid, col.Name, coldef, null, 0, out _);
|
Api.JetAddColumn(_session, tableid, col.Name, coldef, null, 0, out _);
|
||||||
}
|
}
|
||||||
|
|
||||||
string indexKey = $"+{_primaryKey.Name}\0";
|
string indexName = "primary";
|
||||||
int keyLength = Encoding.ASCII.GetByteCount(indexKey + "\0"); // double null-terminated
|
string key = $"+{_primaryKey.Name}\0";
|
||||||
string fullKeyDescription = indexKey + "\0";
|
string keyDescription = key + "\0"; // double null-terminated
|
||||||
|
int keyDescriptionLength = Encoding.ASCII.GetByteCount(keyDescription); // in characters
|
||||||
|
|
||||||
Api.JetCreateIndex(
|
Api.JetCreateIndex(
|
||||||
_session,
|
_session,
|
||||||
tableid,
|
tableid,
|
||||||
"primary",
|
indexName,
|
||||||
CreateIndexGrbit.IndexPrimary | CreateIndexGrbit.IndexUnique,
|
CreateIndexGrbit.IndexPrimary | CreateIndexGrbit.IndexUnique,
|
||||||
fullKeyDescription,
|
keyDescription,
|
||||||
keyLength,
|
keyDescriptionLength,
|
||||||
100
|
100
|
||||||
);
|
);
|
||||||
|
|
||||||
Api.JetCommitTransaction(_session, CommitTransactionGrbit.None);
|
|
||||||
Api.JetCloseTable(_session, tableid);
|
Api.JetCloseTable(_session, tableid);
|
||||||
|
Api.JetCommitTransaction(_session, CommitTransactionGrbit.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CacheColumns()
|
private void CacheColumns()
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,16 @@ namespace WelsonJS.Launcher.Storage
|
||||||
public JET_CP CodePage { get; set; }
|
public JET_CP CodePage { get; set; }
|
||||||
public bool IsPrimaryKey { get; set; } = false;
|
public bool IsPrimaryKey { get; set; } = false;
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static explicit operator string(Column c)
|
||||||
|
{
|
||||||
|
return c.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
public Column(string name, JET_coltyp type, int maxSize = 0, JET_CP codePage = JET_CP.None)
|
public Column(string name, JET_coltyp type, int maxSize = 0, JET_CP codePage = JET_CP.None)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user