I have a typed dataset set that I fill by scrapping an HTML page, and getting the information I need.
I fill my datatable with 600 odd rows, then call my dataadapter to update the Database. The problem is that it adds the first row, but not any other of the rows. I get this error message
"Column 'PriceID' is constrained to be unique. Value '6' is already present." The row that is added to the database is given the PriceID of 6.
The PriceID field is the primary key, Autoincrement field on a SQL Server database. My typed dataset is auto generated by VB.Net and I've not had problems with the mass inserts of data in the passed.
VB Code:
Dim dt As ds.PricesDataTable = ds.Ds1.Prices For Each cp In HS.Prices Dim dr As ds.PricesRow = dt.NewPricesRow dr.ProductID = cp.ProductID dr.CurrentPrice = cp.Price dr.UpdateTime = CDate(Format(Now, "dd/MM/yyyy")) dt.Rows.Add(dr) Next Try ds.PricesDA.Update(ds.Ds1.Prices) Catch ex As Exception Debug.WriteLine(ex.Message) End Try




Reply With Quote