Friday, February 24, 2012

cannot insert null

i am using asp2003 and sql server 2000. in my SQL Server i am generating a field city_id automatically by incrementing the value by 1 and it is the primary key. so when i insert any data using my asp.net application it works fine on my system but it gives me error when i upload it to the web server. the error is

Cannot insert the value NULL into column 'city_id', table 'nevadb.nevauser.city_master'; column does not allow nulls. INSERT fails. The statement has been terminated.

any help?

Are you sure that city_id is an auto incrementing field on the production server? Have you double-checked that?

|||

Try to set this option before you insert data to the table:

SET IDENTITY_INSERT OFF;

INSERT ....

|||yes. this is the problem... actually when i copy my database from my computer to web server using import/export utility of sql server 2000. then it do not copy all the checks (in my case identity). even import/export utility do have option to copy identity values but it is not working the way it should be. can you suggest any solution to me. some one told me that i have to write some kind of script and run it on the server. does anybody have any idea, what i shoul do to resolve this problem.|||well i found the solution... i created sql queries and run it on the server through query analyser. SQL queries can be automatically generated through the enterprise manager, by right clicking on a particular table>>> all tasks >>>> Genetare SQL Script.....
Thank you every body for replying

No comments:

Post a Comment