当前位置:编程学习 > C#/ASP.NET >>

求助~~


问题如图:
代码如下:
if (!IsPostBack) 
        {
            string id = Request["id"];
            SqlConnection ts = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ts"]);
            ts.Open();
            SqlDataAdapter sda = new SqlDataAdapter("select * from FlightInformation where id=" + Request["id"], ts);
            DataSet ds = new DataSet();
            sda.Fill(ds, "FlightInformation");
            DataRowView rowview = ds.Tables["FlightInformation"].DefaultView[0];
            this.company.Text = rowview["company_type"].ToString();
            this.ftype.Text = rowview["flight_type"].ToString();
            Session["sc"] = rowview["starting_city"].ToString();
            Session["ac"] = rowview["terminus_city"].ToString();
            this.aport.Text = rowview["starting_airport"].ToString();
            this.bport.Text = rowview["arriving_airport"].ToString();
            this.aprice.Text = rowview["OneWay_price"].ToString();
            this.bprice.Text = rowview["GoAndBack_price"].ToString();
            this.at.Text = rowview["starting_time"].ToString();
            this.bt.Text = rowview["arriving_time"].ToString();
            Session["tdate"] = rowview["starting_date"].ToString();
            Session["num0"] = rowview["num"].ToString();
            Session["fid"]=rowview["id"].ToString();
            Session["bunktype"] = rowview["bunk_type"].ToString();
            p = Convert.ToInt32(Session["num0"]);
            date.Text = DateTime.Now.ToLongDateString();
            weekdate.Text = DateTime.Today.DayOfWeek.ToString();
        } --------------------编程问答-------------------- 这个查询语句在执行的时候有问题了,where正确的方式应该是 id='某个值'需要加引号的,所以你的代码应该改为:

 SqlDataAdapter sda = new SqlDataAdapter("select * from FlightInformation where id=" + "'"+Request["id"]+"'", ts);
--------------------编程问答-------------------- 检查你SQL语句。
把调试得到的SQL语句放到查询分析器看下是否可执行。
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,