I've tried reading through datareader from the database.
Tried dataadapter, reading from dataset and datatable.
All of them generates an error when reading empty rows. Yes, I have used try and catch statements but the error still generated, that is transforming only in a messagebox.
What I want is to completely remove the error when reading empty table rows.
I have a hidden textbox that is being incremented for every successful register.
SqlDataAdapter da = new SqlDataAdapter("SELECT MAX(Transaction_No) AS Transaction_No FROM Transactions", con);
da.Fill(ds);
DataTable dt = new DataTable();
dt = ds.Tables[0];
if (dt.Rows.Count > 0)
{
textBox1.Text = (Convert.ToInt32(dt.Rows[0]["Transaction_No"]) + 1).ToString();
}
It has no try and catch, but I already said that even it is included, the error is still being generated, only transformed into a messagebox. I also tried adding an else statement, but no good.