mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-10-26 18:41:18 +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 _);
|
||||
}
|
||||
|
||||
string indexKey = $"+{_primaryKey.Name}\0";
|
||||
int keyLength = Encoding.ASCII.GetByteCount(indexKey + "\0"); // double null-terminated
|
||||
string fullKeyDescription = indexKey + "\0";
|
||||
string indexName = "primary";
|
||||
string key = $"+{_primaryKey.Name}\0";
|
||||
string keyDescription = key + "\0"; // double null-terminated
|
||||
int keyDescriptionLength = Encoding.ASCII.GetByteCount(keyDescription); // in characters
|
||||
|
||||
Api.JetCreateIndex(
|
||||
_session,
|
||||
tableid,
|
||||
"primary",
|
||||
indexName,
|
||||
CreateIndexGrbit.IndexPrimary | CreateIndexGrbit.IndexUnique,
|
||||
fullKeyDescription,
|
||||
keyLength,
|
||||
keyDescription,
|
||||
keyDescriptionLength,
|
||||
100
|
||||
);
|
||||
|
||||
Api.JetCommitTransaction(_session, CommitTransactionGrbit.None);
|
||||
Api.JetCloseTable(_session, tableid);
|
||||
Api.JetCommitTransaction(_session, CommitTransactionGrbit.None);
|
||||
}
|
||||
|
||||
private void CacheColumns()
|
||||
|
|
|
|||
|
|
@ -17,6 +17,16 @@ namespace WelsonJS.Launcher.Storage
|
|||
public JET_CP CodePage { get; set; }
|
||||
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)
|
||||
{
|
||||
Name = name;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user