i have problem with query the database.
i want to add data into two table that share same Primary key. here my code
error message :The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.
Dim con As New OleDb.OleDbConnection(My.Settings.KK3DB)
Dim com As New OleDb.OleDbCommand
Dim adap As New OleDb.OleDbDataAdapter
Dim ds As New DataSet
con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\User\Desktop\dia\14052012\KK3MailingSystem\KK3MailingSystem\db\KK3MailingSystem.mdb;Persist Security Info=True")
con.Open()
com.CommandText = " INSERT INTO Staff (Staff_Id,Staff_Name, Staff_IC,Staff_Ext,Staff_HP,Staff_Email,Staff_Position) VALUES ('" + txtId.Text + "','" + txtName.Text + "','" + txtIC.Text + "','" + txtExt.Text + "','" + txtHP.Text + "','" + txtEmail.Text + "','" + txtPosition.Text + "')"
com.Connection = con
com.ExecuteNonQuery()< error here
com.CommandText &= " INSERT INTO Login (Staff_Id, Staff_Username) VALUES ('" + txtId.Text + "','" + txtUsername.Text + "')"
com.Connection = con
com.ExecuteNonQuery()
adap = New OleDbDataAdapter("select * from Staff", con)
adap.Fill(ds, "1")
StaffDataGridView.DataSource = ds.Tables("1")
Me.StaffDataGridView.Rows(Me.StaffDataGridView.RowCount - 2).Selected = True