做了一个管理预定客房的页面 代码如下。
从菜单点进去就显示网络连接错误,是页面代码的错误吗,还是其他错误。
求大神指导。
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;using Business;
using System.Data.SqlClient;public partial class Customer_BookRoom : System.Web.UI.Page
{
    business b = new business();
    static string sortRule;
    static DataView dv;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Bind();
            sortRule = "";
        }
        Label1.Text = Session["cusname"].ToString();
    }
    protected void Bind()
    {
        string connstring = "server=.\\sqlexpress;database=HotelRoomManagement;Integrated Security=SSPI";
        SqlConnection conn = new SqlConnection(connstring);
        //SqlCommand cmd = new SqlCommand("select * from checkinsituation where cusname='" + Session["cusname"].ToString() + "'", conn);
        SqlCommand cmd = new SqlCommand("select roomid,cusname,checkintime,checkouttime,reservecheckintime,reservecheckouttime,deposit from checkinsituation where cusname=@cusname", conn);
        cmd.Parameters.AddWithValue("cusname", Session["cusname"].ToString());
        SqlDataAdapter sda = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        sda.Fill(ds, "t1");
        GridView1.DataSource = ds.Tables["t1"];
        GridView1.DataBind();
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string nid = GridView1.DataKeys[e.RowIndex].Value.ToString();
        string connstring = "server=.\\sqlexpress;database=HotelRoomManagement;Integrated Security=SSPI";
        SqlConnection conn = new SqlConnection(connstring);
        conn.Open();
        SqlCommand cmd = new SqlCommand("delete from checkinsituation where customerID='" + nid + "'", conn);
        int res = cmd.ExecuteNonQuery();
        conn.Close();
        if (res > 0)
            Response.Write("<script>alert('success')</scrip>");
        GridView1.EditIndex = -1;
        Bind();
    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "update")
        {
            Response.Redirect("../Customer/BookRoom2.aspx"); 
        }
    }
}