01.
string
sqlCommandString =
"SELECT MAX(WARRANTY_ID) AS Expr1 FROM TB_WARANTY"
;
02.
SqlCommand sqlCommand =
new
sqlCommand(sqlCommandString, sqlConnection);
03.
04.
object
Result = 0;
05.
06.
try
07.
{
08.
sqlConnection.Open();
09.
Result = sqlCommand.ExecuteScalar();
10.
sqlConnection.Close();
11.
}
12.
catch
(Exception ex)
13.
{
14.
MessageBox.Show(ex.Message);
15.
}
16.
17.
int
ans = (
int
)Result;