Exception: Primary key information is not present

csharp New Zealand
  • 16 years ago

    AoA Dears,


    i m having a problem with inserting value in SQL Server 2000 through C# Code
    the table in which i m going to insert values have a composite primary key(combination of 4 DataColumns)
    when i load DataSet, i set these four DataColumns as primary key using following C# code


    DataColumn[] keys = new DataColumn[4];
    keys[0] = dsRole.Tables["SECURITYGROUPROLES"].Columns["GROUPID"];
    keys[1] = dsRole.Tables["SECURITY
    GROUPROLES"].Columns["ROLETYPE"];
    keys[2] = dsRole.Tables["SECURITYGROUPROLES"].Columns["CATEGORY_ID"];


    keys[3] = dsRole.Tables["SECURITYGROUPROLES"].Columns["FORUM_ID"];


    dsRole.Tables["SECURITYGROUPROLES"].PrimaryKey = keys;


    when i update existing record in this table, it works fine. but when i insert new record in this table, it gives an error at Updateing DataSet that


    [SqlServerCommandBuilder] ConcreteGetInsertCommand()Primary key information is not present


    i have already set primay key but why its giving this error


    Can any body tell me the solution of this problem


    One point more. DataTable that have a single column as primary key, are working fine. But having composite key is not working fine
    waiting for ur urgent reply


    Thanks in advance


    Maqsood Ahmad

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.” - Antoine de Saint Exupéry