js wrote:
hi,
how to create dao.tabledef object in asp:
I need to convert the following code into asp:
Dim tdf As DAO.TableDef
Dim db As DAO.Database
Dim fld As DAO.Field
Set db = OpenDatabase("C:\Mydb.mdb")
Set tdf = db.TableDefs("Table1")
Set fld = tdf.CreateField("Field2", dbText, 10)
tdf.Fields.Append fld
Please help. Thanks.
DAO is a single-threaded COM object whose use is vehemently discouraged in
ASP.
There are several other ways to create tables in Access databases including
ADOX and SQL DDL. Mike's already provided a link to an ADOX article, so let
me describe the DDL variation:
Simply create a sql statement containing the appropriate DDL (Data
Definition Language) and use a connection object to execute it. For your
example, I would use:
sql="CREATE TABLE Table1 (Field2 TEXT(10))"
The appropriate datatype keywords can be found in Access online help (look
at the table of contents and expand the Microsoft Jet SQL Reference node,
drilling down until you get to the "SQL Data Types" topic
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.