Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

Help with ADOX

Discussion in 'Information Technology' started by Staats, Jul 28, 2006.

Tags:
  1. Staats

    Staats
    Expand Collapse
    Guest

    Good evening all. I am having a problem creating a table with ADOX.
    Dim tblTemp As ADOX.Table
    Dim cat As ADOX.Catalog
    Dim clmTemp As ADOX.Column

    Set cat = New ADOX.Catalog
    cat.ActiveConnection = CurrentProject.Connection

    On Error Resume Next
    cat.Tables.Delete "tblTypebyDist"
    ' ********************************8change after finishing!
    On Error GoTo 0
    ' ^^^^^^^^^^^^^^^6
    Set tblTemp = New ADOX.Table
    tblTemp.Name = "tblTypeByDist"

    tblTemp.Columns.Append "Volume", adInteger
    tblTemp.Columns.Append "Length", adInteger
    tblTemp.Columns.Append "Class", adInteger
    tblTemp.Columns.Append "WIM", adInteger
    tblTemp.Columns.Append "PRV", adInteger
    tblTemp.Columns.Append "PRL", adInteger
    tblTemp.Columns.Append "PRC", adInteger
    tblTemp.Columns.Append "PRW", adInteger
    tblTemp.Columns.Append "Dist", adVarChar, 10 <-------- ERROR WITH THIS
    STATEMENT


    cat.Tables.Append tblTemp
    cat.Tables.Refresh
    For Each clmTemp In tblTemp.Columns
    ' Debug.Print clmTemp.Name
    Next clmTemp

    Set tblTemp = Nothing
    Set cat = Nothing

    ********************************************************************************************
    In the code above, it will run as long as the TYPEs of columns being
    appended are 'adInteger'. I get errors when trying to add a column with
    the type as advarchar. Any Ideas?

    Thanks in advance.
    ~Garrett
     
  2. Loading...


  3. RoyVidar

    RoyVidar
    Expand Collapse
    Guest

    > Good evening all. I am having a problem creating a table with ADOX.
    > Dim tblTemp As ADOX.Table
    > Dim cat As ADOX.Catalog
    > Dim clmTemp As ADOX.Column
    >
    > Set cat = New ADOX.Catalog
    > cat.ActiveConnection = CurrentProject.Connection
    >
    > On Error Resume Next
    > cat.Tables.Delete "tblTypebyDist"
    > ' ********************************8change after finishing!
    > On Error GoTo 0
    > ' ^^^^^^^^^^^^^^^6
    > Set tblTemp = New ADOX.Table
    > tblTemp.Name = "tblTypeByDist"
    >
    > tblTemp.Columns.Append "Volume", adInteger
    > tblTemp.Columns.Append "Length", adInteger
    > tblTemp.Columns.Append "Class", adInteger
    > tblTemp.Columns.Append "WIM", adInteger
    > tblTemp.Columns.Append "PRV", adInteger
    > tblTemp.Columns.Append "PRL", adInteger
    > tblTemp.Columns.Append "PRC", adInteger
    > tblTemp.Columns.Append "PRW", adInteger
    > tblTemp.Columns.Append "Dist", adVarChar, 10 <-------- ERROR WITH
    > THIS STATEMENT
    >
    >
    > cat.Tables.Append tblTemp
    > cat.Tables.Refresh
    > For Each clmTemp In tblTemp.Columns
    > ' Debug.Print clmTemp.Name
    > Next clmTemp
    >
    > Set tblTemp = Nothing
    > Set cat = Nothing
    >
    > ********************************************************************************************
    > In the code above, it will run as long as the TYPEs of columns being
    > appended are 'adInteger'. I get errors when trying to add a column
    > with the type as advarchar. Any Ideas?
    >
    > Thanks in advance.
    > ~Garrett


    I think perhaps adVarChar maps to Jet 3.51 text fields and SQL server
    varchar fields, but try adVarWChar for Jet 4.0 fields.

    Here's a little "map" - whatch for linebreaks in the link
    http://www.carlprothman.net/Technology/DataTypeMapping/tabid/97/Default.aspx

    --
    Roy-Vidar
     
  4. Staats

    Staats
    Expand Collapse
    Guest

    Thanks for the help and the link to the various data types - that is a
    great bit of info. I couldn't find a table like that in the white
    pages... :(
    ~GS
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page