Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modify Fields Propertied with ADOX ?

Status
Not open for further replies.

amigo02

Programmer
Feb 19, 2003
109
0
0
Hi there
I have a master database (ms access 2000) that I use to develop my application and I modify it almost daily. My application is being used by several client companies already and I want to reflect those master database changes on their current databases too.

To accomplish that I wrote the following vb.net code
The code supposed to find the new tables in master table and replicate them in current client database

catMaster.ActiveConnection = oConnMaster
catCurrent.ActiveConnection = oConnCurrent

On Error Resume Next
For Each tblmaster In catMaster.Tables
i = 0
If tblmaster.Type = "TABLE" And InStr(tblmaster.Name, "~") <= 0 And InStr(tblmaster.Name, "TempTable") <= 0 And tblmaster.Name <> "Paste Errors" Then ' type 1 is the user tables
For Each tblcurrent In catCurrent.Tables
If tblmaster.Name = tblcurrent.Name Then
'exists
i = 1
End If
Next
If i = 0 Then 'table does not exists in current database
Label1.Text = Label1.Text & "TABLE =" & tblmaster.Name & " is being appended<br>"
tbltemp = New ADOX.Table()
tbltemp.Name = tblmaster.Name
For Each col In tblmaster.Columns
colnew = New ADOX.Column()
colnew.Attributes = col.Attributes
colnew.DefinedSize = col.DefinedSize
colnew.Name = col.Name
colnew.NumericScale = col.NumericScale
colnew.ParentCatalog = col.ParentCatalog
colnew.Precision = col.Precision
For Each p In col.Properties
colnew.Properties(p.Name).Value = p.Value
Next
tbltemp.Columns.Append(colnew)
Next
catCurrent.Tables.Append(tbltemp)
End If
End If

Next


above code gives me the following error:
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
 
These two statements

Code:
tbltemp = New ADOX.Table()

colnew = New ADOX.Column()

are creating objects (table and column respectively). They should be

Code:
[b]Set[/b] tbltemp = New ADOX.Table()

[b]Set[/b] colnew = New ADOX.Column()
 
I don't think you need the "set" keyword in vb.net anymore!

am I correct?

And I isolated the problem to column attributes. For example I can't set the col property for a null value etc.

I still don't have a solution to this problem
 
In other words the problem is with the following code:

For Each p In col.Properties
colnew.Properties(p.Name).Value = p.Value
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top