What is wrong with this code? I want to catch the last value from SQL row and display it in a TextBox. Kindly help me.
private void textBox2_Leave(object sender, EventArgs e)
{
cmd.Connection = cn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select last(remain) from item_new_customer where cust=" + textBox2.Text + "";
float h = (float)cmd.ExecuteScalar();
textBox20.Text = h.ToString();
}
lastbut your code sample saysmax. What issues are you seeing?single quotes like 'for textbox value, also look into parameterized queries