Hi,
I getting a error while try to fetch a ID +1 number(int) into a textbox.
This is the sql server query: -
SELECT MAX(SlabID)+1 FROM INVSTSLAB
The error is below:-
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Abhay ShankerPosted Nov 12, 2014, 5:50 AM
So first check query its returning max+1 value
Also Modify the code as below
while(rdr.Read())
{
txtSlabID.Text = rdr["SlabID"].ToString();
}
rdr.Close();
cn.Close();
Bineesh ViswanathPosted Nov 12, 2014, 5:25 AM
it was the mistake from sql query.
Corrected SQl Query:-
SELECT max(cast(SlabID as int)) + 1 as SlabID
Corrcted C# code :-
txtSlabID.Text = rdr["SlabID"].ToString();