C
Chris
Hello,
The following code works fine, but I need to set the `ISBN` to be the
primary key. I'm using ADO, C# and haven't come across anything that google
could help me with.
Any pointers/tips/help would be appreciated....Thank you for your time....
public bool CreateDataBase()
{
Catalog myCatalog = new ADOX.CatalogClass();
ADOX.IndexClass myIndex = new ADOX.IndexClass();
string dbPath =
System.IO.Directory.GetCurrentDirectory()+@"\BookCollection.mdb";
// build the database
myCatalog.Create("Provider=Microsoft.Jet.OLEDB.4.0;"+"Data
Source="+dbPath+";"+"Jet OLEDB:Engine Type=5");
// build the tables
Table myTable = new TableClass();
myTable.Columns.Append("ISBN",DataTypeEnum.adVarWChar,20);
myTable.Columns["ISBN"].ParentCatalog=myCatalog;
myTable.Columns.Append("Title",DataTypeEnum.adVarWChar,20);
myTable.Columns.Append("Author",DataTypeEnum.adVarWChar,20);
myTable.Columns.Append("Publisher",DataTypeEnum.adVarWChar,20);
myTable.Columns.Append("Cost",DataTypeEnum.adCurrency,10);
myTable.Name = "BookCollection";
// append the tables
myCatalog.Tables.Append(myTable);
return true;
}
The following code works fine, but I need to set the `ISBN` to be the
primary key. I'm using ADO, C# and haven't come across anything that google
could help me with.
Any pointers/tips/help would be appreciated....Thank you for your time....
public bool CreateDataBase()
{
Catalog myCatalog = new ADOX.CatalogClass();
ADOX.IndexClass myIndex = new ADOX.IndexClass();
string dbPath =
System.IO.Directory.GetCurrentDirectory()+@"\BookCollection.mdb";
// build the database
myCatalog.Create("Provider=Microsoft.Jet.OLEDB.4.0;"+"Data
Source="+dbPath+";"+"Jet OLEDB:Engine Type=5");
// build the tables
Table myTable = new TableClass();
myTable.Columns.Append("ISBN",DataTypeEnum.adVarWChar,20);
myTable.Columns["ISBN"].ParentCatalog=myCatalog;
myTable.Columns.Append("Title",DataTypeEnum.adVarWChar,20);
myTable.Columns.Append("Author",DataTypeEnum.adVarWChar,20);
myTable.Columns.Append("Publisher",DataTypeEnum.adVarWChar,20);
myTable.Columns.Append("Cost",DataTypeEnum.adCurrency,10);
myTable.Name = "BookCollection";
// append the tables
myCatalog.Tables.Append(myTable);
return true;
}