Re: ADOX Column Creation Problem



The following example uses JET OLEDB Provider and creates the table in
Access. I am creating the columns in a numeric sequence and displaying it
back again at the end. The columns are not renamed and I also looked at the
table in Access and observed no change in the column names

------------------------------------------------------------------------------------------------
Dim cn As New ADODB.Connection
Dim cat As New ADOX.Catalog
Dim tbl As New ADOX.Table
Dim tblname As String
Dim lc As Integer

'JET OLEDB provider
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\SampleDb.mdb;"

'Table name to be created
tblname = "testtable"

cat.ActiveConnection = cn

'Delete the table if it exists
For Each tbl In cat.Tables
If tbl.Name = tblname Then cat.Tables.Delete tblname
Next

tbl.Name = tblname

tbl.Columns.Append "fld1", adSmallInt
tbl.Columns.Append "fld2", adDate
tbl.Columns.Append "fld3", adDouble
tbl.Columns.Append "fld4", adInteger

cat.Tables.Append tbl

'Check for table
Set tbl = Nothing
Set tbl = cat.Tables(tblname)

'Loop through columns in the table
MsgBox tbl.Columns.Count
For lc = 0 To tbl.Columns.Count - 1
MsgBox tbl.Columns.Item(lc).Name
Next lc
------------------------------------------------------------------------------------------------



"Scott McBurney" <ScottMcBurney@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:85BE6F7C-3874-42A7-AFEB-77D6874F9A42@xxxxxxxxxxxxxxxx
>I have just discovered an issue with ADOX that is causing problems for us.
>
> I am currently using VB6 and ADOX to create a table in an access database.
>
> There are several columns in the table that are named in a numeric
> sequence...ie we have 4 fields named Custom1, Custom2, Custom3, and
> Custom4.
>
> When the access database is created and we open it with access, those
> columns have been renamed to Custom, Custom1, Custom2, and Custom3.
>
> This is causing a HUGE problem!!! Is there any way to avoid this
> problem?
>
> --
> Scott McBurney
> Software Developer
> LexisNexis Interface Software, Inc.


.



Relevant Pages

  • Re: Losing textbox on table
    ... 'lastmonth' calendar in the left of the 'sub' table, ... [MVP - Microsoft Word] ... Dim dt As Date ... Dim tbl As Table ...
    (microsoft.public.word.tables)
  • Re: Losing textbox on table
    ... insert the 'thismonth' calendar in the main table, ... [MVP - Microsoft Word] ... Dim dt As Date ... Dim tbl As Table ...
    (microsoft.public.word.tables)
  • Sum in a dynamic query
    ... Private Sub Form_Open ... Dim db As Database, Tbl As TableDef ... Dim db As Database, qd As QueryDef, ctl As Control, s As String, Item As ...
    (comp.databases.ms-access)
  • Re: Losing textbox on table
    ... These two "small months" will be placed in one of the cells of the month. ... Dim dt As Date ... Dim tbl As Table ...
    (microsoft.public.word.tables)
  • Re: Losing textbox on table
    ... I have checked out your Microsoft link and the only one that comes close to ... These two "small months" will be placed in one of the cells of the month. ... Dim dt As Date ... Dim tbl As Table ...
    (microsoft.public.word.tables)