I'm building an applications that uses an access database. I can successfully add a new row, but when i add a second row i get the error:
System.Data.ConstraintException occurred in System.Data.dll
Column "Name" is constrained to be unique. Value "katy" is already present.
There is only 1 record in the database with Name value Kevin, so the value katy is not present.
Here is the code:
Public Class Checkin
Dim checkin As Camping_databaseDataSet.CampingRow
Private Sub Checkin_Load(sender As Object, e As EventArgs) Handles MyBase.Load
arrivalpick.Text = DateAndTime.Now
checkin = Camping_databaseDataSet.Camping.NewCampingRow()
CampingTableAdapter.Fill(Camping_databaseDataSet.Camping)
Camping_databaseDataSet.Camping.NewCampingRow()
End Sub
Private Sub BtnSaveRecord_Click(sender As Object, e As EventArgs) Handles BtnSaveRecord.Click
checkin.ArrivalDate = CDate(arrivalpick.Text)
checkin.City = txtcity.Text
If chkconnection.Checked = True Then
checkin.Connection = True
Else
checkin.Connection = False
End If
checkin.Country = txtcountry.Text
checkin.Name = txtname.Text
checkin.NoAdults = adultcount.Text
checkin.NoCaravan = caravancount.Text
checkin.NoChildren = childcount.Text
checkin.NoDogs = dogcount.Text
checkin.NoGrey = greycount.Text
checkin.NoMobilhome = mobilhomecount.Text
checkin.NoShowercoins = showercoincount.Text
checkin.NoTent = tentcount.Text
checkin.NoTransport = transportcount.Text
checkin.NoYellow = yellowcount.Text
checkin.Street = txtstreet.Text
checkin.EndEdit()
Camping_databaseDataSet.Camping.Rows.Add(checkin)
Me.CampingTableAdapter.Update(Me.Camping_databaseDataSet)
Camping_databaseDataSet.Camping.AcceptChanges()
End Sub
End Class
What am i doing wrong?

