ADOX in .Net

G

Guest

Hi,

I am attempting to change an Access 2000 mdb's field's AllowZeroLength
property to true using .Net 1.1 SP1 and having trouble getting it to work.
It seems that I am not adding the updated column to the catalog, and am not
sure how to do this. Any help would be greatly appreciated!

ADOX.CatalogClass thisCatalog;
ADOX.TableClass thisTable;

try
{
thisCatalog = new ADOX.CatalogClass();
thisCatalog.ActiveConnection = strAccessConn + "Jet OLEDB:Engine Type=5;";
// Type=5 => Access 2000 format

thisTable = new ADOX.TableClass();
thisTable.Name = "tblGroups";
thisTable.ParentCatalog = thisCatalog;

thisTable.Columns["UserIDs"].Properties["Jet OLEDB:Allow Zero
Length"].Value = true;

}
catch(Exception ex)
{
log.WriteToLog(log.FormatExceptionDescription("ADOX Error", ex));
}
finally
{
thisCatalog = null;
thisTable = null;
}
 
P

Paul Clement

¤ Hi,
¤
¤ I am attempting to change an Access 2000 mdb's field's AllowZeroLength
¤ property to true using .Net 1.1 SP1 and having trouble getting it to work.
¤ It seems that I am not adding the updated column to the catalog, and am not
¤ sure how to do this. Any help would be greatly appreciated!
¤
¤ ADOX.CatalogClass thisCatalog;
¤ ADOX.TableClass thisTable;
¤
¤ try
¤ {
¤ thisCatalog = new ADOX.CatalogClass();
¤ thisCatalog.ActiveConnection = strAccessConn + "Jet OLEDB:Engine Type=5;";
¤ // Type=5 => Access 2000 format
¤
¤ thisTable = new ADOX.TableClass();
¤ thisTable.Name = "tblGroups";
¤ thisTable.ParentCatalog = thisCatalog;
¤
¤ thisTable.Columns["UserIDs"].Properties["Jet OLEDB:Allow Zero
¤ Length"].Value = true;
¤
¤ }
¤ catch(Exception ex)
¤ {
¤ log.WriteToLog(log.FormatExceptionDescription("ADOX Error", ex));
¤ }
¤ finally
¤ {
¤ thisCatalog = null;
¤ thisTable = null;
¤ }

If doesn't look to me as if you are referencing the existing Table called tblGroups, but creating a
new table and setting the Name to "tblGroups".

Try replacing:

¤ thisTable.Name = "tblGroups";

With:

thisTable = thisCatalog.Tables["tblGroups"];


Paul
~~~~
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top