Query issue in C#
624071Feb 19 2008 — edited Feb 19 2008I am trying to set up a query to populate a bunch of textboxes with the field from my query. In the query I need to make sure that the nulls are taken care of so I have nvl int he select statement. I anyone know why I am getting the following error and how to fix your help would be greatly appreciated. Thanks in advance.
ERROR: (the section in bold is where the error occurs)
IndexOutOfRangeException was unhandled
Index was outside the bounds of the array.
OracleConnection conn = new OracleConnection(constr);
conn.Open();
// Execute a SQL SELECT
OracleCommand cmd_ = conn.CreateCommand();
cmd_.CommandText =
"select nvl(address, ' '), nvl(account, ' '), nvl(sw_pidn, ' '), nvl(metersvc, ' ') from watermeters where customer = '"
+ Customer_name.Text + "'";
OracleDataReader dr = cmd_.ExecuteReader();
dr.Read();
Account_number.Text = dr.GetString(3);
Customer_address.Text = dr.GetString(5);
PID.Text = dr.GetString(10);
Land_type.Text = dr.GetString(7);
cmd_.Dispose();
conn.Dispose();
}
}