I know this question has been on this site many times, but I can't get my code working.
I have an Insert
statement, and I need the id from that statement on my asp.net page.
I'm getting the return value 0
.
public int newid { get; set; }
public void CreateAlbum(string _titel, string _name, string _thumb, int _userid)
{
objCMD = new SqlCommand(@"INSERT INTO tblFotoalbum
(fldAlbumHead, fldAlbumName, fldAlbumThumb, fldUserID_FK)
VALUES
(@titel, @name, @thumb, @userid);
SET @newid = SCOPE_IDENTITY()");
objCMD.Parameters.AddWithValue("@titel", _titel);
objCMD.Parameters.AddWithValue("@name", _name);
objCMD.Parameters.AddWithValue("@thumb", _thumb);
objCMD.Parameters.AddWithValue("@userid", _userid);
objCMD.Parameters.AddWithValue("@newid", newid);
objData.ModifyData(objCMD);
}
SELECT SCOPE_IDENTITY()
– AdmitobjData
and what does.ModifyData()
on that object do?? – Osmium