G
Gus M
Hi,
I've got a bit of a problem, and from what I've read on here it should
be very easy but I just can't get it to work.
I've got a dataset of my table, and using a tableadapter I've created a
insert command through the wizard. This is all good except that I want
it to return the value SCOPE_IDENTITY() so that I know the PK (set to
auto increment) of the inserted row. If I edit the SQL command through
query builder so that it goes from:
-------------------
INSERT INTO [contact details]
(cnt_phone, cnt_fax, cnt_mobile_number,
cnt_direct_phone, cnt_extension, cnt_direct_fax, cnt_contact_address_1,
cnt_contact_address_2,
cnt_contact_address_3, cnt_suburb, cnt_city,
cnt_state, cnt_postcode, cnt_country, cnt_postal_address_one,
cnt_postal_address_two,
cnt_postal_address_three,
cnt_postal_address_four, cnt_website_address, cnt_email_address,
cnt_alternate_email, cnt_date_table_last_updated,
cnt_history,
cnt_table_last_updated_by_per_id_link)
VALUES
(@cnt_phone,@cnt_fax,@cnt_mobile_number,@cnt_direct_phone,@cnt_extension,@cnt_direct_fax,@cnt_contact_address_1,@cnt_contact_address_2,@cnt_contact_address_3,@cnt_suburb,@cnt_city,@cnt_state,@cnt_postcode,@cnt_country,@cnt_postal_address_one,@cnt_postal_address_two,@cnt_postal_address_three,@cnt_postal_address_four,@cnt_website_address,@cnt_email_address,@cnt_alternate_email,@cnt_date_table_last_updated,@cnt_history,@cnt_table_last_updated_by_per_id_link)
-------------------
to having this added onto the end:
----------------------
GO
SELECT cnt_id
WHERE cnt_id = SCOPE_IDENTITY()
-----------------
I get an "Unable to parse query text." error message.
I've been doing a lot of research on this and from what I've read this
should all work. I've changed the command type over from
ExecuteNonQuery to Scalar but it still doesn't work.
I'm using VS2005 release and SQL server 2005 release.
Any help would be great as I'm tearing my hair out at the moment!!
Thanks,
Gus.
I've got a bit of a problem, and from what I've read on here it should
be very easy but I just can't get it to work.
I've got a dataset of my table, and using a tableadapter I've created a
insert command through the wizard. This is all good except that I want
it to return the value SCOPE_IDENTITY() so that I know the PK (set to
auto increment) of the inserted row. If I edit the SQL command through
query builder so that it goes from:
-------------------
INSERT INTO [contact details]
(cnt_phone, cnt_fax, cnt_mobile_number,
cnt_direct_phone, cnt_extension, cnt_direct_fax, cnt_contact_address_1,
cnt_contact_address_2,
cnt_contact_address_3, cnt_suburb, cnt_city,
cnt_state, cnt_postcode, cnt_country, cnt_postal_address_one,
cnt_postal_address_two,
cnt_postal_address_three,
cnt_postal_address_four, cnt_website_address, cnt_email_address,
cnt_alternate_email, cnt_date_table_last_updated,
cnt_history,
cnt_table_last_updated_by_per_id_link)
VALUES
(@cnt_phone,@cnt_fax,@cnt_mobile_number,@cnt_direct_phone,@cnt_extension,@cnt_direct_fax,@cnt_contact_address_1,@cnt_contact_address_2,@cnt_contact_address_3,@cnt_suburb,@cnt_city,@cnt_state,@cnt_postcode,@cnt_country,@cnt_postal_address_one,@cnt_postal_address_two,@cnt_postal_address_three,@cnt_postal_address_four,@cnt_website_address,@cnt_email_address,@cnt_alternate_email,@cnt_date_table_last_updated,@cnt_history,@cnt_table_last_updated_by_per_id_link)
-------------------
to having this added onto the end:
----------------------
GO
SELECT cnt_id
WHERE cnt_id = SCOPE_IDENTITY()
-----------------
I get an "Unable to parse query text." error message.
I've been doing a lot of research on this and from what I've read this
should all work. I've changed the command type over from
ExecuteNonQuery to Scalar but it still doesn't work.
I'm using VS2005 release and SQL server 2005 release.
Any help would be great as I'm tearing my hair out at the moment!!
Thanks,
Gus.