Re: Updating column property on table gives error
- From: "Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx>
- Date: Wed, 20 Sep 2006 10:38:09 -0400
Could it be that you are modifying the ParentCatalog property again in
your loop, thus setting it to the source catalog and causing a duplicate
column to be appended to the source table?
Uwe wrote:
If I move the append after updating the properties, which workedhttp://msdn.microsoft.com/library/en-us/ado270/htm/mdmscmicrosoftadoprogrammersreference.asp
without errors I get an error trying to append the column.
run-time error -214721887(80040e21) multiple step OLE DB operation
generated errors...
Just to clarify, this function is trying to update an application
.mdb from a template .mdb with changes to queries and tables.
--
Thanks,
Uwe
"Bob Barrows [MVP]" wrote:
Uwe wrote:
When it tries to update the column properties it appears that they
are read only and errors where I marked the code with #######.
Set oRecord = New ADODB.Recordset
oRecord.Open "Select * From [" & oTableSource.Name & "]",
oTableSource.ParentCatalog.ActiveConnection, adOpenForwardOnly
For Each oField In oRecord.Fields
Set colMD = oTableSource.Columns(oField.Name)
With colMD
If Not ExistsColumn(.Name, oTableDest) Then
Set colDB = New ADOX.Column
With colDB
.ParentCatalog = catDest
.Name = colMD.Name
.Type = colMD.Type
.DefinedSize = colMD.DefinedSize
.Attributes = colMD.Attributes
End With
oTableDest.Columns.Append colDB
' *** Now as the column is added, set all it's
properties For i = 0 To colMD.Properties.Count - 1
####### colDB.Properties(i).Value =
colMD.Properties(i).Value
These properties are read/write ONLY UNTIL the column is appended to
a Columns collection, after which they become read-only. See the ADOX
documentation at:
--
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.
--
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.
.
- References:
- Re: Updating column property on table gives error
- From: Bob Barrows [MVP]
- Re: Updating column property on table gives error
- Prev by Date: Re: Updating column property on table gives error
- Next by Date: Re: Updating column property on table gives error
- Previous by thread: Re: Updating column property on table gives error
- Next by thread: Re: Updating column property on table gives error
- Index(es):