Try
builder.GetUpdateCommand()
myDataAdapter.UpdateCommand = builder.GetUpdateCommand()
ds.Tables(0).Columns(1).Unique = True
Dim myUC As UniqueConstraint
Dim mytable As DataTable = ds.Tables(0)
Try
myUC = New UniqueConstraint("UC", ds.Tables(0).Columns(1))
'ds.Tables(0).Constraints.Add(myUC)
Catch ukex As ConstraintException
MessageBox.Show("Column contents are not Unique", "Duplicate Data", MessageBoxButtons.OK, MessageBoxIcon.Stop)
'Catch uniqEx As Exception
'MessageBox.Show(uniqEx.Message)
Exit Sub
End Try
myDataAdapter.Update(ds, "myDataset")
MessageBox.Show("Your data is Saved", "Save Successful!")
Catch ex As Exception
MessageBox.Show("Name: saveData" + vbCrLf + "Error Message: " + ex.ToString)
End Try
|