snobrdinrtiste
Programmer
Can someone help me with this... i'm stumped
how can I add a primary key to an Access table I created using ADOX.
here's my code:
ADODB.Connection sqlconAdo = new ADODB.Connection();
ADOX.Catalog sqlcatAdox = new ADOX.Catalog();
ADOX.Table sqltableAdox = new ADOX.Table();
ADOX.Key sqlKeyAdox = new ADOX.Key();
sqlconAdpen("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strDbFile, "", "", -1);
sqlcatAdox.ActiveConnection = sqlconAdo;
sqltableAdox.Name = strTableName;
sqltableAdox.ParentCatalog = sqlcatAdox;
sqltableAdox.Columns.Append("ID", ADOX.DataTypeEnum.adInteger, 3);
sqltableAdox.Columns["ID"].Properties["Autoincrement"].Value = true;
sqltableAdox.Columns["ID"].Properties["Nullable"].Value = false;
sqltableAdox.Columns["ID"].Properties["Jet OLEDB:Allow Zero Length"].Value = false;
sqltableAdox.Columns.Append("DEPTID", ADOX.DataTypeEnum.adInteger, 3);
sqltableAdox.Columns["DEPTID"].Properties["Nullable"].Value = false;
sqltableAdox.Columns["DEPTID"].Properties["Jet OLEDB:Allow Zero Length"].Value = false;
sqltableAdox.Columns.Append("SUBSECTION", ADOX.DataTypeEnum.adVarWChar, 10);
sqltableAdox.Columns["SUBSECTION"].Properties["Nullable"].Value = false;
sqltableAdox.Columns["SUBSECTION"].Properties["Jet OLEDB:Allow Zero Length"].Value = false;
sqlcatAdox.Tables.Append(sqltableAdox);
how can I add a primary key to an Access table I created using ADOX.
here's my code:
ADODB.Connection sqlconAdo = new ADODB.Connection();
ADOX.Catalog sqlcatAdox = new ADOX.Catalog();
ADOX.Table sqltableAdox = new ADOX.Table();
ADOX.Key sqlKeyAdox = new ADOX.Key();
sqlconAdpen("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strDbFile, "", "", -1);
sqlcatAdox.ActiveConnection = sqlconAdo;
sqltableAdox.Name = strTableName;
sqltableAdox.ParentCatalog = sqlcatAdox;
sqltableAdox.Columns.Append("ID", ADOX.DataTypeEnum.adInteger, 3);
sqltableAdox.Columns["ID"].Properties["Autoincrement"].Value = true;
sqltableAdox.Columns["ID"].Properties["Nullable"].Value = false;
sqltableAdox.Columns["ID"].Properties["Jet OLEDB:Allow Zero Length"].Value = false;
sqltableAdox.Columns.Append("DEPTID", ADOX.DataTypeEnum.adInteger, 3);
sqltableAdox.Columns["DEPTID"].Properties["Nullable"].Value = false;
sqltableAdox.Columns["DEPTID"].Properties["Jet OLEDB:Allow Zero Length"].Value = false;
sqltableAdox.Columns.Append("SUBSECTION", ADOX.DataTypeEnum.adVarWChar, 10);
sqltableAdox.Columns["SUBSECTION"].Properties["Nullable"].Value = false;
sqltableAdox.Columns["SUBSECTION"].Properties["Jet OLEDB:Allow Zero Length"].Value = false;
sqlcatAdox.Tables.Append(sqltableAdox);