: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
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

Catch ex As Exception
End Try

da.Update(ds, "HostingDB")
MsgBox("New Record added to the Database")
End If
End Sub

Thanks in advance!

As the Column 'ID' is unique, before inserting giv a check for existing ID and proceed with inserting to the database. or else create the ID as autonumber and insert the rest columns. so with this, access with increment the ID field with 1 and you can add the column without any error.