Re: ADOX Column Creation Problem
- From: "Raj Kasi" <lkasi@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 20 Sep 2005 16:30:21 -0700
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.
.
- Prev by Date: Re: Error accessing Oracle date fields
- Next by Date: Re: Help in migrating DAO to ADO in VB 6
- Previous by thread: Error accessing Oracle date fields
- Next by thread: Re: Help in migrating DAO to ADO in VB 6
- Index(es):
Relevant Pages
|
|