On Fri, 12 Oct 2001 [EMAIL PROTECTED] wrote: > Here is the VB sample. I did the steps to create the database > (except I created it in Access 2000), and create a new table. I > also created the AutoNumber ID column, except I am stuck on the > parts about setting parent catalog and setting autoincrement to > true. Then, I created a primary key. So, I guess my question is: > how do I translate the parent catalog thing and the autoincrement > thing into Python?
import os, win32com.client try: os.unlink("./new35.mdb") except: pass oCat = win32com.client.Dispatch("ADOX.Catalog") oTable = win32com.client.Dispatch("ADOX.Table") oColumn = win32com.client.Dispatch("ADOX.Column") oKey = win32com.client.Dispatch("ADOX.Key") oCat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\\new35.mdb;") oTable.Name = "WebSite" oCat.Tables.append(oTable) oColumn.Name = "WebSiteID" oColumn.Type = win32com.client.constants.adInteger oColumn.ParentCatalog = oCat oColumn.Properties("Autoincrement").Value = 1 oCat.Tables("WebSite").Columns.append(oColumn) oKey.Name = "PrimaryKey" oKey.Type = 1 # win32com.client.constants.adKeyPrimary oKey.RelatedTable = "WebSite" oKey.Columns.append("WebSiteID") oCat.Tables("WebSite").Keys.append(oKey) Note that for some reason adKeyPrimary didn't get exported by COM with the rest of the constants. Maybe the documentation has a misspelling in the name. At any rate the value is 1. I assume from your comment that you wanted the code to create an Access 2000 database instead of an Access 97 db. If that assumption is incorrect, just use the same connection string that the VB code used. -- Bob Kline mailto:[EMAIL PROTECTED] http://www.rksystems.com _______________________________________________ ActivePython mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/activepython