0

using this code.stored procedure

@_Empno nvarchar(8),@_Surname nvarchar(50),
@_Firstname nvarchar(50),
@_Middlenamenvarchar(50),@_PermanentAdd nvarchar(Max),
@_PresentAdd nvarchar(Max),
@_Identity ouput int

AS

SET NOCOUNT ON;
INSERT INTO TblEmpPersonal
(
Empno,
Surname,
Firstname,
Middlename,
PermanentAdd)

values(INSERT INTO TblEmpPersonal
(
@_Empno,
@_Surname,
@_Firstname,
@_Middlename,
@_PermanentAdd)

set @_Identity = (Select cast(scope_identity() as int) as empID)

here my DAL

public static bool Create(IEmployee Emp)
{
SqlParameter[] _parameters = {
new SqlParameter("@_Empno", Emp.Empno),
new SqlParameter("@_Surname",Emp.Surname),
new SqlParameter("@_Firstname", Emp.Firstname),
new SqlParameter("@_Middlename",Emp.Middlename),
new SqlParameter("@_PermanentAdd",Emp.PermanentAdd),
new SqlParameter("@_PresentAdd",Emp.PresentAdd),
new SqlParameter("@_Identity",Emp.Identity)};
return Convert.ToBoolean(connectionString,CommandType.Stor edProcedure,"_Insert_Employee",_parameters));
}

pls help me..
thanx in advance..

Edited by __avd: Added [code] tags. Encase your code in: [code] and [/code] tags.

3
Contributors
2
Replies
5
Views
7 Years
Discussion Span
Last Post by MattBerry
1

I haven't used C in years, but if I remember correctly you need to use

@@IDENTITY

to retrieve the Last ID.

Anyone more familiar, correct me if I'm wrong.

Edited by Banderson: n/a

Votes + Comments
Correct.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.