habib ullah

habib ullah

  • NA
  • 229
  • 14.2k

how to get a maximum id from database on from load event

Apr 10 2018 12:26 PM
how to get a maximum id from database on from load event and assign the textbox
my storeprocedure is that i am beginer pleae help me
alter PROCEDURE School.GetRegisterationNumber
AS
begin
declare @StudentRegNo int
set @StudentRegNo=(select MAX(StudentRegNo) from School.StudentInformation)
if @StudentRegNo is null
set @StudentRegNo='OXPS-0001'
Return 'OXPS'+'-'+RIGHT('0000'+convert(nvarchar(10),@StudentRegNo),4)
SET @StudentRegNo=SCOPE_IDENTITY()
end
c# code is that  
public int GetRegisterAtionNumber()
{
List<SqlParameter> prm = new List<SqlParameter>();
DataSet ds= rp.GetDS("School.GetRegisterationNumber", prm);
DataTable dt = ds.Tables[0];
return 1;
}
 form load event is that
tbx.tex= GetRegisterAtionNumber().tostring();
 
the error is that
Additional information: Conversion failed when converting the nvarchar value 'OXPS-0333' to data type int. 
 

Answers (2)