I want to access the last value in database column increment it by 1 and show on a textbox I used this code but nothing is displayed on text box what's wrong with this code?
SqlCommand cmd = new SqlCommand("SELECT (MAX[Account_No] FROM addcustomer ", my);
int result = ((int)cmd.ExecuteScalar());
textBox1.Text = result.ToString();
resultin this code. Did you spare it out for brevity or forget?)SELECT MAX(Account_No) + 1 FROM addcustomermight work better. This does not solve your first problem though, so may I ask for an exception detail again? You might need to configure Visual Studio to notify you about exceptions, even if wrapped in try/catch blocks: Try Debug, Exceptions and check Thrown for Common Language Runtime Exceptions. This might show you additional information.myto?