Home All Groups Group Topic Archive Search About


Author
8 Mar 2006 5:19 AM
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.

Author
8 Mar 2006 8:11 AM
Mike Brind
js wrote:
Show quote
> 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

--
Mike Brind
Author
8 Mar 2006 3:27 PM
Bob Barrows [MVP]
js wrote:
Show quote
> 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.
Author
8 Mar 2006 3:54 PM
js
Thansk for the help.

Show quote
"js" <js@some***@hotmail.com> wrote in message
news:%239%23Co$mQGHA.6008@TK2MSFTNGP10.phx.gbl...
> 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.
>
>

AddThis Social Bookmark Button