amigo02
Programmer
- Feb 19, 2003
- 109
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.
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.