N
Newfriend
Guest
Hi there!
I have a main database. I do extraction some data to DataTable and then need to update private database with this data avoiding doubling. When I use Update command, data doubling in a private database, in case of Fill nothing happens at all.
Here the code:
Dim Table As New DataTable
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Main.mdb;Jet OLEDBatabase Password=123")
cmd = New OleDb.OleDbCommand With {.Connection = cn}
cn.Open()
cmd.CommandText = "SELECT * FROM Catalogue"
DA = New OleDbDataAdapter(cmd)
DA.AcceptChangesDuringFill = False
DA.Fill(Table)
DA.Dispose()
cn.Close()
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=private.mdb;Jet OLEDBatabase Password=123"
cmd = New OleDb.OleDbCommand With {.Connection = cn}
cn.Open()
cmd.CommandText = "SELECT * FROM Catalogue"
DA = New OleDbDataAdapter(cmd)
MyBuilder = New OleDbCommandBuilder(DA)
DA.Fill(Table) ADD NO DATA
DA.Update(Table) DOUBLING DATA
DA.Dispose()
cn.Close()
As you understand, when I talk about doubling data, its mean I have already some data in a private database and they can be the same as data in main database.
Problem visualization:
Begining
Main database, table 1 data
1
2
3
Private database, table 1 data
1
2
Ending
What I need:
Private database, table 1 data
1
2
3
What I get:
Private database, table 1 data
1
2
1
2
3
Aleksey
Continue reading...
I have a main database. I do extraction some data to DataTable and then need to update private database with this data avoiding doubling. When I use Update command, data doubling in a private database, in case of Fill nothing happens at all.
Here the code:
Dim Table As New DataTable
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Main.mdb;Jet OLEDBatabase Password=123")
cmd = New OleDb.OleDbCommand With {.Connection = cn}
cn.Open()
cmd.CommandText = "SELECT * FROM Catalogue"
DA = New OleDbDataAdapter(cmd)
DA.AcceptChangesDuringFill = False
DA.Fill(Table)
DA.Dispose()
cn.Close()
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=private.mdb;Jet OLEDBatabase Password=123"
cmd = New OleDb.OleDbCommand With {.Connection = cn}
cn.Open()
cmd.CommandText = "SELECT * FROM Catalogue"
DA = New OleDbDataAdapter(cmd)
MyBuilder = New OleDbCommandBuilder(DA)
DA.Fill(Table) ADD NO DATA
DA.Update(Table) DOUBLING DATA
DA.Dispose()
cn.Close()
As you understand, when I talk about doubling data, its mean I have already some data in a private database and they can be the same as data in main database.
Problem visualization:
Begining
Main database, table 1 data
1
2
3
Private database, table 1 data
1
2
Ending
What I need:
Private database, table 1 data
1
2
3
What I get:
Private database, table 1 data
1
2
1
2
3
Aleksey
Continue reading...