hi
it is my code but i have error!
(error say "The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Person_Groups". The conflict occurred in database "PhoneBookDB", table "dbo.Groups", "GroupID".
The statement has been terminated.
protected void btnEntrance_Click(object sender, EventArgs e)
{
PhoneBookDB.GroupsDataTable group = new PhoneBookDB.GroupsDataTable();
PhoneBookDBTableAdapters.GroupsTableAdapter groupDA = new
PhoneBookDBTableAdapters.GroupsTableAdapter();
groupDA.Fill(group);
groupDA.Insert(ddlRelation.SelectedItem.Text);
PhoneBookDB.PersonDataTable person = new PhoneBookDB.PersonDataTable();
PhoneBookDBTableAdapters.PersonTableAdapter personAD = new PhoneBookDBTableAdapters.PersonTableAdapter();
personAD.Fill(person);
personAD.Insert(txtFirstName.Text, txtLastName.Text, txtPhone.Text, param(), txtAddress.Text, txtOtherPhone.Text, txtFax.Text,Convert.ToInt16(ddlRelation.SelectedValue));
}
public bool param()
{
if (rdbtnMan.Checked)
{
return true;
}
else
{
return false;
}
}
and it is my table
CREATE TABLE [dbo].[Person](
[PersonID] [int] IDENTITY(1,1) NOT NULL,
[FirstName] [nvarchar](50) NOT NULL,
[LastName] [nvarchar](50) NOT NULL,
[Phone] [nchar](20) NOT NULL,
[Sex] [bit] NOT NULL,
[Address] [text] NULL,
[OtherPhone] [nchar](20) NULL,
[Fax] [nchar](20) NULL,
[GroupID] [int] NOT NULL(it is forignkey from group),
and group table
CREATE TABLE [dbo].[Groups](
[GroupID] [int] IDENTITY(1,1) NOT NULL,
[Relation] [nvarchar](20) NOT NULL,