increment with last id , how to get the counted value of particular field in a variable to perform some function using the counted value. {
SqlConnection con = newSqlConnection(@"server=CSE-PC; integrated security=true; Database=Bas");
con.Open();
SqlCommand com = newSqlCommand("select top(1) SUBSTRING(CustomerId,1,0) as Last_Id from devi order by Last_Id desc", con);
strc00 = com.ExecuteScalar().ToString();
com.ExecuteNonQuery();
here i have gave code like this but it does not work any one please give syntax for this question.
if (i == 0) here I need to increment with last id how to get the counted value in a variable.
{
strc00 = "001";
}
else
{
int j = i + 1;
strc00 = "001" + j.ToString();
}
comboBox1.Items.Add(strc00);
i++;
MessageBox.Show("Id Created");
con.Close();
}
}