create object & DAO

Discussion in 'ASP General' started by js, Mar 8, 2006.

  1. js

    js Guest

    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.
    js, Mar 8, 2006
    #1
    1. Advertising

  2. js

    Mike Brind Guest

    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.



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

    --
    Mike Brind
    Mike Brind, Mar 8, 2006
    #2
    1. Advertising

  3. 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.
    Bob Barrows [MVP], Mar 8, 2006
    #3
  4. js

    js Guest

    Thansk for the help.

    "js" <js@> wrote in message
    news:%239%23Co$...
    > 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.
    >
    >
    js, Mar 8, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mirek

    asp.net and dao?

    mirek, Aug 4, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    2,284
    Mirek Rewak
    Aug 6, 2003
  2. SKG

    DAO and RDO and ADO

    SKG, Aug 6, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,553
    Steve C. Orr [MVP, MCSD]
    Aug 6, 2004
  3. Andy Grove
    Replies:
    0
    Views:
    421
    Andy Grove
    Sep 2, 2003
  4. Ed Thompson

    Java Data Access Object Design (DAO)

    Ed Thompson, Sep 17, 2003, in forum: Java
    Replies:
    2
    Views:
    3,092
  5. jon wayne
    Replies:
    9
    Views:
    706
    Jim Langston
    Sep 22, 2005
Loading...

Share This Page