problem updating a row with an identity column

6 views
Skip to first unread message

DaveBurns

unread,
Oct 16, 2009, 11:15:32 AM10/16/09
to DataMgr
Hi. I'm trying out DataMgr (version 2.2.0.2). I have an existing row
in a table that I'm trying to update with:

Application.DataMgr.saveRecord("mytable", info);

I get the error:

Cannot insert explicit value for identity column in table
'mytable' when IDENTITY_INSERT is set to OFF.

The SQL INSERT that DataMgr would replace sets the values of all the
columns except the identity but uses the identity in the WHERE clause:

UPDATE mytable
SET
foo = 1,
bar = 2
WHERE
myID = '#info.ID#'

Is DataMgr supposed to detect identity columns and handle them
smoothly or do I need to do something to make this work? FWIW, the
identity column is not the primary key. There is no primary key
defined for this table. Might that make DataMgr act funky?

Thanks,
Dave

Steve Bryant

unread,
Oct 19, 2009, 11:26:51 PM10/19/09
to dat...@googlegroups.com
Dave,

You hit the nail on the head when you asked about the missing primary
key. DataMgr does need a primary key in order to figure that stuff
out. It may or may not be an identity and can even be a compound
primary key, but without that it doesn't know when to insert and when
to update.

The insertRecord method should (in theory) work without a primary key.
The updateRecord method, however, will not as it doesn't know which
parts of the structure are the SET and which are the WHERE.

The updateRecords method (note the "s" at the end), should work fine:
http://www.bryantwebconsulting.com/docs/datamgr/update-multiple-records.cfm

I'll certainly work on improving the error message returned in this scenario.

Let me know if you need anything else.

Thanks,

Steve

On Fri, Oct 16, 2009 at 10:15 AM, DaveBurns <davebur...@gmail.com> wrote:
>
> Hi. I'm trying out DataMgr (version 2.2.0.2). I have an existing row
> in a table that I'm trying to update with:
>
>    Application.DataMgr.saveRecord("mytable", info);
>
> I get the error:
>
>    Cannot insert explicit value for identity column in table
> 'mytable' when IDENTITY_INSERT is set to OFF.

> There is no primary key

Reply all
Reply to author
Forward
0 new messages