can not update a table via dataset when the table participate in relation

Alex_bg

Member
Joined
Dec 26, 2004
Messages
17
Hello,

I am using MS Access dtb and VB.NET. I am using a dataset where I store the edited values. I am not changing any key values. The problem is that i can not update the dataset when I the table has a field that participates in relation.
For example, if i have a table with three fields:

Product
Description
Client

If "product" participates in relation, if I change the "client" or "description" filed I get error on oledbdataadater.update.

Thanks,
Alex
 
SonicBoomAu said:
Hi Alex,

Can you post youre update code.

Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
Try
OleDbDataAdapter2.Update(Me.Dts_products1)
Catch Ex As System.Exception
MessageBox.Show(Ex.Message)
MessageBox.Show(MainForm.err_string(3))
End Try
End Sub

Private Sub load_data()
Try
Me.OleDbDataAdapter2.Fill(Me.Dts_products1)
Catch Ex As System.Exception
MessageBox.Show(Ex.Message)
MessageBox.Show(MainForm.err_string(2))
End Try
End Sub


Me.OleDbUpdateCommand1.CommandText = "UPDATE Products SET Product = ?, [Product group] = ?, [Main product] = ?, [EIS number] = ?, Description = ? WHERE (Product = ?) AND (Description = ? OR ? IS NULL AND Description IS NULL) AND ([EIS number] = ? OR ? IS NULL AND [EIS number] IS NULL) AND ([Main product] = ? OR ? IS NULL AND [Main product] IS NULL) AND ([Product group] = ? OR ? IS NULL AND [Product group] IS NULL)"
 
Last edited by a moderator:
Code:
WHERE (Product = ?) AND (Description = ? OR ? IS NULL AND Description IS NULL) AND ([EIS number] = ? OR ? IS NULL AND [EIS number] IS NULL) AND ([Main product] = ? OR ? IS NULL AND [Main product] IS NULL) AND ([Product group] = ? OR ? IS NULL AND [Product group] IS NULL)"

You must declare what the product is. It has to be able to identify the Product it has to update.
 
How could I specify what is the product number as I am using as a datagrid binded to the datasource? The datagrid may have many edited records, that need to be updated.
 
Back
Top