每当我想在我的航空公司预订系统项目中预订航班时,我都会在上图中出现此错误,我的代码中出现异常错误,此错误消息正在弹出
IndexOutOfRangeException unhandles by user code
...关于我如何去做的任何想法我的代码是使用 c sharp 在 asp.net 中编写的?
这是代码
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;
}