Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error message explanation

Status
Not open for further replies.

jez

Programmer
Apr 24, 2001
370
VN
Hi,

I have the following query;-
Code:
INSERT INTO media_cart (cart_name, cart_identifier, cart_owner_name, cart_xoops_user_id, cart_status)
VALUES     ('newcart', 'xxx', 'jondoe', '36', '1');
SELECT     SCOPE_IDENTITY() AS cart_ID;

When i run it in the SQL server management studio i get an integer as the result (as expected).

But when run this code in my application (PHP), i get the following error;-

Code:
The active result for the query contains no fields.

Can anyone suggest why this may be happening.
I am trying to get the last inserted Id. Is there is a better way to do it? Suggestions welcome.
 
Try adding 'Set nocount on'. Like this.

Code:
SET NOCOUNT ON
INSERT INTO media_cart (cart_name, cart_identifier, cart_owner_name, cart_xoops_user_id, cart_status)
VALUES     ('newcart', 'xxx', 'jondoe', '36', '1');
SELECT     SCOPE_IDENTITY() AS cart_ID;

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Thanks very much! That works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top