
i am having this error in the image above whenever i want to book a flight in my airline reservation system project there is an exception error in my code this error message was popping up
IndexOutOfRangeException unhandles by user code
...any ideas on how i can go about it my code is written in asp.net using c sharp??
this is code
public partial class TICKET_BOOKING : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
int a;
String constring = ConfigurationManager.ConnectionStrings["conn"].ConnectionString.ToString();
public int Autonumber()
{
SqlConnection con = new SqlConnection(constring);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
con.Open();
cmd.CommandText = "select pid from pid";
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
DataTable dt = new DataTable();
da.SelectCommand = cmd;
da.Fill(dt);
a = Convert.ToInt32(dt.Rows[0][0].ToString()) + 1; //this is where its occuring
con.Close();
return a;
}