Nibble Guru - Computing queries demystified Thursday, January 08, 2009
Home
My Account / Register
Login / Logout
Post your Problem!
Search

About Us
Contact Us



List Home > Programming / Scripting >   [ Post New Problem ]

Welcome back !
TrackingID : 233
Posted : Sunday, November 09th, 2003 10:39:38 AM
By : richardfox
ID of last row insertedConfiguration:
How can I get the primary key of the row I just inserted? I am using the mssql_ functions, MS SQL Server

thanks,

Rich

Additional Comments:
Also how can I do it in MySQL
Operating System : MS Windows 98

Related Problems :
Comments :
Re: id of last row inserted by nibbleguru on November 09th, 2003 10:41:07 AM
In mySql, use mysql_insert_id().

For MS SQL Server try
$query = "SELECT @@IDENTITY";
Re: ID of last row inserted by Anonymous Ghost on November 09th, 2003 10:45:02 AM
using @@identity may faile in different cases. I do it like that. I add a additional column with default NULL to the table. When inserting a new row i put a value in that column. Then I search for the row with that value and take the ID from that row. For preaparing the next insert you have to set the value in the additional colllum to Null.
Re: ID of last row inserted by richardfox on November 09th, 2003 10:48:40 AM
thx, it worked.
Re: ID of last row inserted by Anonymous Ghost on August 23rd, 2004 04:04:36 AM
UserWorkflow userWorkflow = new UserWorkflow();
userWorkflow.addUser(userBean);
List userDTOFromDB = userWorkflow.getCompanyAdmins(userBean.getCompanyID()
Re: ID of last row inserted by Anonymous Ghost on August 23rd, 2004 04:09:20 AM
how to get ID from company using in user
action
UserWorkflow userWorkflow = new UserWorkflow();
userWorkflow.addUser(userBean);
List userDTOFromDB = userWorkflow.getCompanyAdmins(userBean.getCompanyID())
Re: ID of last row inserted by Anonymous Ghost on November 16th, 2004 02:23:13 PM
sadfsadf

Related Problems :
Post a Note :
UserName (not required in anonymous posts)
Password (not required in anonymous posts)
Post Anonymous (check this only if you wish to post anonymously.)
Subject
Comment (limited HTML allowed)



List Home > Programming / Scripting >   [ Post New Problem ]
Copyright © 2001-2009, Nibble Guru