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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting the last id

Status
Not open for further replies.

orangeblue

Programmer
Nov 26, 2002
107
GB
Hi
I need to get the last id of the record i have inserted in s sql sever db.

i know in asp i can use @@identity but what to i do with asp.net


the insert code is below
cmdinsert = new sqlCommand("sp_Insert_event", myConnection)
cmdInsert.CommandType = COMMANDTYPE.storedProcedure

cmdInsert.Parameters.Add("@frm_event_type", lstFAQs.text)
cmdInsert.Parameters.Add("@frm_date", cdate(Eventdate.text))
cmdInsert.Parameters.Add("@frm_time", lsttime.text)


cmdInsert.Parameters.Add("@frm_location", txt_location.text)
cmdInsert.Parameters.Add("@frm_desc", frm_desc.text)



and my store proc id


CREATE PROCEDURE sp_insert_event

@frm_event_type int,
@frm_date datetime,
@frm_time nvarchar(10),
@frm_location nvarchar(100),
@frm_desc text,
@id int output



AS


insert tble_events
(
events_type,
events_date,
events_time,
events_location,
events_notes

)
values
(
@frm_event_type,
@frm_date,
@frm_time,
@frm_location,
@frm_desc
)


SELECT @ID = @@identity
GO


please can anyone explain how to do this
thanks
hesh
 
For future reference, there is a forum specifically for ASP.Net located here: forum855

barcode_1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top