M
Muhammad Usman
hi,
I have a table of student which contain four fields that
are id(primary key number) , name(text),semester(text)and
corse(text), When I insert values in a student
table.Explorer Show the follwing exception string.
"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."
I am using different values in the code that are not
already exist in table.
The code for insertion is given below.
try
{
OleDbConnection con=new
OleDbConnection(@"provider=microsoft.jet.oledb.4.0 ; data
source=D:\Inetpub\wwwroot\ado_net\test.mdb");
string isql="INSERT INTO
student VALUES(14,'sam','4th','ACCP')";
OleDbCommand ins=new
OleDbCommand(isql,con);
ins.Connection.Open();
ins.ExecuteNonQuery();
ins.Connection.Close();
}
catch(Exception ec)
{
Response.Write
(ec.Message.ToString());
}
Please solve my problem, i am using c# as code behind.
Thanks
Muhammad Usman.
I have a table of student which contain four fields that
are id(primary key number) , name(text),semester(text)and
corse(text), When I insert values in a student
table.Explorer Show the follwing exception string.
"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."
I am using different values in the code that are not
already exist in table.
The code for insertion is given below.
try
{
OleDbConnection con=new
OleDbConnection(@"provider=microsoft.jet.oledb.4.0 ; data
source=D:\Inetpub\wwwroot\ado_net\test.mdb");
string isql="INSERT INTO
student VALUES(14,'sam','4th','ACCP')";
OleDbCommand ins=new
OleDbCommand(isql,con);
ins.Connection.Open();
ins.ExecuteNonQuery();
ins.Connection.Close();
}
catch(Exception ec)
{
Response.Write
(ec.Message.ToString());
}
Please solve my problem, i am using c# as code behind.
Thanks
Muhammad Usman.