R
Rico
Hello,
Well, I guess I obviously don't fully understand the updatecommand. I
thought the when you create a DA, that the accompanying update command would
only modify the records that had changed. I'm grabbing three records that
contain serial numbers related to an order detail item. (i.e. there are
three serial numbers associated with the same product / orderdetail line).
When I update one serial number in the datagrid and run the update against
it, it updates ALL the serial numbers in the database to the new value.
Here is what I have, and any help would be greatly appreciated.
daEditSerials = mdi.dt.GenericDA("SELECT
VendorOrderDetailSerialNumbers.SerialNumberID,VendorOrderDetailSerialNumbers.OrderDetailID,
VendorInventoryTypes.Description,
VendorOrderDetailSerialNumbers.SerialNumber FROM VendorInventoryTypes INNER
JOIN (VendorOrderItems INNER JOIN VendorOrderDetailSerialNumbers ON
VendorOrderItems.OrderDetailID =
VendorOrderDetailSerialNumbers.OrderDetailID) ON
VendorInventoryTypes.VendorInventoryTypesID =
VendorOrderItems.VendorInventoryTypesID WHERE
VendorOrderDetailSerialNumbers.OrderDetailID=" & OrderID & " ORDER BY
VendorInventoryTypes.Description,
VendorOrderDetailSerialNumbers.SerialNumber;")
daEditSerials.UpdateCommand = mdi.dt.GenericDACommand("UPDATE
VendorOrderDetailSerialNumbers SET
SerialNumber=@SerialNumber,OrderDetailID=@OrderDetailID")
daEditSerials.UpdateCommand.Parameters.Add("@SerialNumber",
OleDb.OleDbType.Char, 50, "SerialNumber")
daEditSerials.UpdateCommand.Parameters.Add("@OrderDetailID",
OleDb.OleDbType.Integer, 8, "OrderDetailID")
Try
daEditSerials.Fill(dsEditSerials, "SerialDetails_Edit")
dgSerialNumbers.DataSource =
dsEditSerials.Tables("SerialDetails_Edit").DefaultView
Catch ex As Exception
MsgBox(ex.Message & " " & ex.GetBaseException.Message)
End Try
---- Then when it's time to update the DA....
Try
daEditSerials.Update(dsEditSerials, "SerialDetails_Edit")
Catch ex As Exception
MsgBox(ex.Message & " " & ex.GetBaseException.Message)
End Try
Well, I guess I obviously don't fully understand the updatecommand. I
thought the when you create a DA, that the accompanying update command would
only modify the records that had changed. I'm grabbing three records that
contain serial numbers related to an order detail item. (i.e. there are
three serial numbers associated with the same product / orderdetail line).
When I update one serial number in the datagrid and run the update against
it, it updates ALL the serial numbers in the database to the new value.
Here is what I have, and any help would be greatly appreciated.
daEditSerials = mdi.dt.GenericDA("SELECT
VendorOrderDetailSerialNumbers.SerialNumberID,VendorOrderDetailSerialNumbers.OrderDetailID,
VendorInventoryTypes.Description,
VendorOrderDetailSerialNumbers.SerialNumber FROM VendorInventoryTypes INNER
JOIN (VendorOrderItems INNER JOIN VendorOrderDetailSerialNumbers ON
VendorOrderItems.OrderDetailID =
VendorOrderDetailSerialNumbers.OrderDetailID) ON
VendorInventoryTypes.VendorInventoryTypesID =
VendorOrderItems.VendorInventoryTypesID WHERE
VendorOrderDetailSerialNumbers.OrderDetailID=" & OrderID & " ORDER BY
VendorInventoryTypes.Description,
VendorOrderDetailSerialNumbers.SerialNumber;")
daEditSerials.UpdateCommand = mdi.dt.GenericDACommand("UPDATE
VendorOrderDetailSerialNumbers SET
SerialNumber=@SerialNumber,OrderDetailID=@OrderDetailID")
daEditSerials.UpdateCommand.Parameters.Add("@SerialNumber",
OleDb.OleDbType.Char, 50, "SerialNumber")
daEditSerials.UpdateCommand.Parameters.Add("@OrderDetailID",
OleDb.OleDbType.Integer, 8, "OrderDetailID")
Try
daEditSerials.Fill(dsEditSerials, "SerialDetails_Edit")
dgSerialNumbers.DataSource =
dsEditSerials.Tables("SerialDetails_Edit").DefaultView
Catch ex As Exception
MsgBox(ex.Message & " " & ex.GetBaseException.Message)
End Try
---- Then when it's time to update the DA....
Try
daEditSerials.Update(dsEditSerials, "SerialDetails_Edit")
Catch ex As Exception
MsgBox(ex.Message & " " & ex.GetBaseException.Message)
End Try