S
Sam
1. I'm creating an Access database on the fly using ADOX via COM
Interop.
2. I create a CatalogClass, create TableClass and append ColumnClass to
the table as required.
3. In one such table, I have two text fields (adVarWChar) called
"CutterID" and "Material".
4. I want to define a primary key consisting of both the columns taken
together, i.e. the combination of CutterID and Material is to be unique
for each record.
5. To do so I used the sample on
http://support.microsoft.com/default.aspx?scid=kb;en-us;252908
6. My code looks as follows-
// Have to use the ADOX.Key object
ADOX.KeyClass key = new ADOX.KeyClass();
key.Name = "PrimaryKey";
key.Type = ADOX.KeyTypeEnum.adKeyPrimary;
// These columns have been appended to the tbl before calling this
key.Columns.Append ("CutterID", ADOX.DataTypeEnum.adVarWChar, 0);
key.Columns.Append ("Material", ADOX.DataTypeEnum.adVarWChar, 0);
// THE NEXT LINE CHOKES
tbl.Keys.Append (key , ADOX.KeyTypeEnum.adKeyPrimary, "", "", "");
7. The tbl.Keys.Append call throws exception "Exception from HRESULT:
0x800A0BB9." which means "adErrInvalidArgument:The arguments are of the
wrong type, are out of acceptable range, or are in conflict with one
another." (see
http://msdn.microsoft.com/library/d...s_2004main/htm/_sna_number_property_oledb.asp)
8. Help with the tbl.Keys.Append syntax please. I've tried every
permutation & combination.
9. Thanks
Sam.
Interop.
2. I create a CatalogClass, create TableClass and append ColumnClass to
the table as required.
3. In one such table, I have two text fields (adVarWChar) called
"CutterID" and "Material".
4. I want to define a primary key consisting of both the columns taken
together, i.e. the combination of CutterID and Material is to be unique
for each record.
5. To do so I used the sample on
http://support.microsoft.com/default.aspx?scid=kb;en-us;252908
6. My code looks as follows-
// Have to use the ADOX.Key object
ADOX.KeyClass key = new ADOX.KeyClass();
key.Name = "PrimaryKey";
key.Type = ADOX.KeyTypeEnum.adKeyPrimary;
// These columns have been appended to the tbl before calling this
key.Columns.Append ("CutterID", ADOX.DataTypeEnum.adVarWChar, 0);
key.Columns.Append ("Material", ADOX.DataTypeEnum.adVarWChar, 0);
// THE NEXT LINE CHOKES
tbl.Keys.Append (key , ADOX.KeyTypeEnum.adKeyPrimary, "", "", "");
7. The tbl.Keys.Append call throws exception "Exception from HRESULT:
0x800A0BB9." which means "adErrInvalidArgument:The arguments are of the
wrong type, are out of acceptable range, or are in conflict with one
another." (see
http://msdn.microsoft.com/library/d...s_2004main/htm/_sna_number_property_oledb.asp)
8. Help with the tbl.Keys.Append syntax please. I've tried every
permutation & combination.
9. Thanks
Sam.