Skip to content
Advertisement

How to convert last insert id into string?

I have a create account page and on the page I have one button to insert all the details into two seperate tables one of the tables Pictures is dependant on the User table 1:1 relationship via UserID.

I have written some code to try get the last insert id so I can insert into the pictures table:

Not sure if this is correct and I also need to know how to convert the select statement into a string so I can retrieve the UserID from the User table, see database structure:

enter image description here

EDIT

}

Advertisement

Answer

You can use a query similar to the following to post a record, then get the ID.

Note the SELECT SCOPE_IDENTITY() AS ‘ID’ at the end of the query.

and

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement