create object & DAO

J

js

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.
 
M

Mike Brind

js said:
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.


You need to use ADOX: http://www.mikebrind.com/article.asp?id=4
 
B

Bob Barrows [MVP]

js said:
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
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top