CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 View Identity Field

Print topic Send  topic

Author Message
defiantclass1

Posts: 24
Posted: 12/16/2005, 7:40 AM

Hello,

I am creating a page from a table in SQL Server that is an Identity field that increments by 1 with each new record.

I just want to be able to view this field on my page. I do not intend to try and enter the next number in the field manually. But it seems that just having that field present in the form is enough to cause an error when adding a new record. The error I get is:

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

I understand why it doesn't want to do it, but it doesn't understand that I don't really want to add that value, just see it as it does it by itself. (View Only)

Any ideas? Thanks!
View profile  Send private message
Paul Shearing
Posted: 12/16/2005, 10:57 AM

It isn't clear from your enquiry whether you are attempting to add the value via CCS or, say, a Stored Procedure. if you are adding the field via CCS then it is probably trying to explicity enter a value in the identity column. Normally this isn't permitted, hence the error, but you could try executing the following Transact SQL statement prior to performing the record insert:

SET IDENTITY_INSERT TableName ON

the full syntax is:

SET IDENTITY_INSERT [ database. [ owner. ] ] { table } { ON | OFF }

Lookup [Set Indentity] in the SQL 2000 transact SQL books online for full details and examples.

This should permit CCS to add the record without the error.

Perhaps someone else could help with the CCS implications of this - I'm a CCS neophyte but well experienced with SQL 2000.

Kind regards

Paul



peterr


Posts: 5971
Posted: 12/16/2005, 11:12 AM

Regarding CCS implementation, I think that this should work as long as the Identity field is placed on the page as a label rather than a textbox.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Dave
Posted: 12/16/2005, 11:22 AM

I give it shot, thanks a bunch guys!
Walter Kempees
Posted: 12/16/2005, 12:32 PM

Hey Guys,

He just want ro VIEW the data Not Insert/Not update delete it.
As he said
Quote :
I just want to be able to view
Quote :
is enough to cause an error[/unquote]

He is going to RecordForm with no ID on the URL, so the form goes for
InsertMode!

I think he just has to set the RecordForm Allow Insert/Allow Update/Allow
Delete to NO.
The thing I am wondering about is how is he selecting the record?
I think he forgot to mention there actually is a Grid first -> RecordForm.

Otherwise he has to built a RecordForm with Insert/Update/Delete Allowed =
No,
have an input textbox and some custom select a record based on the inputed
ID.

Walter

"defiantclass1" <defiantclass1@forum.codecharge> schreef in bericht
news:643a2dfdd9dc24@news.codecharge.com...
> Hello,
>
> I am creating a page from a table in SQL Server that is an Identity field
> that
> increments by 1 with each new record.
>
> I just want to be able to view this field on my page. I do not intend to
> try
> and enter the next number in the field manually. But it seems that just
> having
> that field present in the form is enough to cause an error when adding a
> new
> record. The error I get is:
>
> Cannot insert explicit value for identity column in table 'TableName' when
> IDENTITY_INSERT is set to OFF.
>
> I understand why it doesn't want to do it, but it doesn't understand that
> I
> don't really want to add that value, just see it as it does it by itself.
> (View
> Only)
>
> Any ideas? Thanks!
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

SK ASHIR
Posted: 01/06/2006, 1:58 AM

Quote :
ASP
ASP
I have an identity field, after insert i want to retrive that indetity number into label/textbox, how i will do with normal insert, generated by wizard

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.