Hello,
I am a novice user of ADOX who is attempting to create a database and
a table in it.
I seem to be able to create a SQL Express database but am unable to
add a table to it.
The attached script (adox.py) illustrates the difficulty.
Any suggestions would be appreciated.
Thanks,
-- jv
'''
a script that illustrates how to create a database/table via ADOX
'''
import os
from win32com.client import Dispatch
catalog = Dispatch('ADOX.Catalog')
host = os.environ['COMPUTERNAME']
server = '%s%sSQLEXPRESS' % (host,os.sep)
database = 'foobar'
tablename = 'spam'
adInteger = 3
adVarChar = 200
try:
catalog.Create('Provider=SQLNCLI;Server=%s;Database=%s;Trusted_Connection=yes;'
% (server, database))
table = Dispatch('ADOX.Table')
table.Name = tablename
table.Columns.Append('CustID', adInteger)
table.Columns.Append('CustName', adVarChar, 30)
table.Keys.Append('PK_CustID', 1, 'CustID')
catalog.Tables.Append(table)
finally:
del catalog
#~ the above script fails at line 22 (catalog.Tables.Append(table)) as follows:
#~ Traceback (most recent call last):
#~ File "adox.py", line 22, in ?
#~ catalog.Tables.Append(table)
#~ File
"C:\Python24\lib\site-packages\win32com\gen_py\00000600-0000-0010-8000-00AA006D2EA4x0x2x8.py",
line 612, in Append
#~ return self._oleobj_.InvokeTypes(1610809345, LCID, 1, (24, 0), ((12,
1),),Item
#~ pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft
SQL Native Client', 'The parameter is incorrect.', None, 0, -2147024809), None)
_______________________________________________
Python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32