Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Identity columns and read only error
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
00880168
Message ID:
00880560
Vues:
15
Mike,


>When I run the following code against a table with a primary key that is an identity column in SQL Server, I get the error "Column 'pri_key' is Read Only"

>DataSet DS = oMyBizObj.GetByID(1);
>
>// Add a DataRow to a table.
>DataRow myRow = DS.Tables["MyTable"].NewRow();
>myRow["MyColumn1"] = 1;
>myRow["MyColumn2"] = "ABC";
>
>// Add the row.
>DS.Tables["MyTable"].Rows.Add( myRow );
>DS.AcceptChanges();
>
>oMyBizObj.UpdateFromDataSet(DS);

Even though you are not programmatically setting the value of the primary key, is it bound to a user interface control? If so, you should set the control to ReadOnly.

Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform