我正在尝试使用以下代码插入新记录后立即从表中获取最大值。
objDataAccess.CmdText("Insert into Patientdetails(Patient_Name,Patient_Age,Patient_Sex,Patient_RfdDr,LabId,Sample_Rcvd,Sample_Dlvd,AmtToPay,AmtPaid,AmtPending)Values('" + Name + "','" + Age + "'," + sex + ",'" + doctor + "'," + LabId + "," + smprcvd + ",'" + smpdlvrd + "'," + AmtoPay + "," + AmtPaid + ","+AmtPndg+")");
dtpid = objDataAccess.CmdSelect("Select Max(Patient_Id) from Patientdetails");
如果我放置断点并检查,我将获得以前的记录最大值,然后它会从我插入的表中获取准确的(新输入的记录)值。
我怎样才能得到最后插入的值