:eek: Hi,
Im having problems in adding new records in a database connected to .net. The data type of ID in access is NUMBER. When I click SAVE it shows this error message: "Column 'ID' is constrained to be unique. Value '1' is already present."
Here is the code for SAVE..
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
If inc <> -1 Then
NavigateRecords()
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsNewRow As DataRow
dsNewRow = ds.Tables("HostingDB").NewRow()
dsNewRow.Item("ID") = txtCiD.Text
dsNewRow.Item("CName") = txtCName.Text
dsNewRow.Item("PCont") = txtPCont.Text
Try
ds.Tables("HostingDB").Rows.Add(dsNewRow)
Catch ex As Exception
MsgBox(ex.Message)
End Try
da.Update(ds, "HostingDB")
MsgBox("New Record added to the Database")
End If
End Sub
Thanks in advance!