none
为什么编译完asp.net,放到网上去,第一次访问时有个数值从数据库里面查不出来!!! RRS feed

  • 问题

  • 我编译完asp.net,放到网上去,第一次访问时有个数值从数据库里面查不出来(具体是用户填入的用户名和数据库中的值进行对比,第一次访问该页面时,数据库里已经存在了这个用户名,还能正常插入进去,而以后就不行了),请解答!先谢谢大家了!
    2012年7月13日 10:28

答案

  • 你应该一点一点定位,把运行有问题的代码贴出来

    比如一个方法,参数,输入值,输出值


    windows live Id :hellohongfu@hotmail.com

    2012年7月15日 9:38

全部回复

  • 请贴相关代码...我来帮你看看..没代码不好判断!
    2012年7月13日 11:02
    版主
  • 请贴相关代码...我来帮你看看..没代码不好判断!

    新手写的代码,有点繁琐,请见谅!

    public partial class protectAdd : System.Web.UI.Page
        {
            Model.CustomerInfo model = new Model.CustomerInfo();
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    DataSet ds = new DataSet();
                    ds = new BLL.LoupanAction().GetLPList();
                    ddlLP.DataSource = ds;
                    ddlLP.DataTextField = "Title";
                    ddlLP.DataValueField = "ID";
                    ddlLP.DataBind();
                    ddlLP.Items.Insert(0, "请选择");
                    string upId = Request.QueryString["upid"];
                    int id;
                    if (!string.IsNullOrEmpty(upId) && int.TryParse(upId, out id))
                    {
                        model = new BLL.CustomerAction().GetModel(id);
                        txtName.Text = model.Title;
                        txtPhone.Text = model.Photo;
                        txtPhone.Enabled = false;
                        txtCaid.Text = model.Inum;
                        if (txtCaid.Text != "")
                        {
                            txtCaid.Enabled = false;
                        }
                        txtRelName.Text = model.Relationtitle;
                        txtRelPhone.Text = model.RelationPhoto;
                        txtName.Enabled = false;
                        string gx = model.Relation;
                        if (gx != "父母" && gx != "兄弟" && gx != "姐妹" && gx != "朋友")
                        {
                            ddlRel.ClearSelection();
                            ddlRel.Items.FindByValue("其他").Selected = true;
                            txtRel1.CssClass = "show";
                            txtRel1.Text = gx;
                        }
                        else
                        {
                            ddlRel.ClearSelection();
                            ddlRel.Items.FindByValue(gx).Selected = true;
                        }
                        btnSub.Text = "保存";
                        string lp = model.Titles;
                        ddlLP.Items.FindByText(lp).Selected = true;
                        ddlLP.Enabled = false;

                        lbNum.Text = model.Numberday;
                        txtContent.Text = model.Contenttitle;
                    }
                }
            }

            protected void btnSub_Click(object sender, EventArgs e)
            {
                //修改
                if (!string.IsNullOrEmpty(Request.QueryString["upid"]))
                {
                    if (txtRelName.Text == "" || txtRelPhone.Text == "")
                    {
                        JsHelper.Alert("信息填写不完整", this);
                        return;
                    }
                    if (ddlLP.SelectedValue == "其他" && txtRel1.Text == "")
                    {
                        JsHelper.Alert("请填写关系类型", this);
                        return;
                    }
                    if (ddlRel.SelectedIndex == 0)
                    {
                        JsHelper.Alert("请选择关系类型,请重新输入", this);
                        return;
                    }
                    Regex cpw = new Regex(@"^(13[0-9]|15[0-9]|18[0-9])\d{8}$");
                    if (txtRelPhone.Text != "")
                    {
                        if (!cpw.IsMatch(txtRelPhone.Text))
                        {
                            JsHelper.Alert("关系人手机号码的格式不正确,请重新输入", this);
                            return;
                        }
                    }
                    if (txtCaid.Text != "")
                    {
                        Regex cp = new Regex(@"^(^\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$");
                        if (!cp.IsMatch(txtCaid.Text))
                        {
                            JsHelper.Alert("身份证号码输入格式不正确", this);
                            return;
                        }
                    }
                    if (txtCaid.Text != "" && txtCaid.Enabled == true)
                    {
                        string phone = "123";
                        if (new BLL.CustomerAction().Exists(phone, txtCaid.Text, int.Parse(ddlLP.SelectedValue)))
                        {
                            JsHelper.Alert("该身份证号码已注册!", this);
                            return;
                        }
                    }
                    model.ID = int.Parse(Request.QueryString["upid"]);
                    model.Title = txtName.Text.Trim();
                    model.Modifytime = DateTime.Now;
                    model.Modefyname = Request.Cookies["loginInfo"]["UserName"];
                    model.Inum = txtCaid.Text.Trim();
                    model.Contenttitle = txtContent.Text.Trim();
                    model.Relationtitle = txtRelName.Text.Trim();
                    model.Type = 1;
                    if (ddlRel.SelectedValue == "其他")
                    {
                        model.Relation = txtRel1.Text;
                    }
                    else
                    {
                        model.Relation = ddlRel.SelectedValue;
                    }
                    model.RelationPhoto = txtRelPhone.Text.Trim();
                    model.Photo = txtPhone.Text.Trim();
                    if (new BLL.CustomerAction().UpdateZJ(model))
                    {
                        ltlSave.Text = "修改成功";
                    }
                    else
                    {
                        Maticsoft.Common.MessageBox.Show(this, "修改失败,请联系管理员!");
                    }
                }
                else
                {
                    if (txtName.Text == "" || txtPhone.Text == "" || txtRelName.Text == "" || txtRelPhone.Text == "")
                    {
                        JsHelper.Alert("信息填写不完整", this);
                        return;
                    }
                    if (ddlLP.SelectedValue == "其他" && txtRel1.Text == "")
                    {
                        JsHelper.Alert("请填写关系类型", this);
                        return;
                    }
                    if (ddlRel.SelectedIndex == 0)
                    {
                        JsHelper.Alert("请选择关系类型,请重新输入", this);
                        return;
                    }
                    if (ddlLP.SelectedIndex == 0)
                    {
                        JsHelper.Alert("请选择楼盘,请重新输入", this);
                        return;
                    }
                    if (txtCaid.Text != "")
                    {
                        Regex cp = new Regex(@"^(^\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$");
                        if (!cp.IsMatch(txtCaid.Text))
                        {
                            JsHelper.Alert("身份证号码输入格式不正确", this);
                            return;
                        }
                    }
                    Regex cpw = new Regex(@"^(13[0-9]|15[0-9]|18[0-9])\d{8}$");
                    if (txtPhone.Text != "")
                    {
                        if (!cpw.IsMatch(txtPhone.Text))
                        {
                            JsHelper.Alert("手机号码的格式不正确,请重新输入", this);
                            return;
                        }
                    }
                    if (txtRelPhone.Text != "")
                    {
                        if (!cpw.IsMatch(txtRelPhone.Text))
                        {
                            JsHelper.Alert("关系人手机号码的格式不正确,请重新输入", this);
                            return;
                        }
                    }
                    if (new BLL.CustomerAction().ExistsName(txtName.Text.Trim()))
                    {
                        //比较时间
                        model = new BLL.CustomerAction().GetTime(txtName.Text.Trim());
                        DateTime t1 = DateTime.Now;
                        if (!string.IsNullOrEmpty(model.Stoptime.ToString()))
                        {
                            int n = t1.CompareTo(model.Stoptime);
                            if (n < 0)
                            {
                                if (txtCaid.Text != "" && txtPhone.Text != "")
                                {
                                    if (new BLL.CustomerAction().Exists(txtPhone.Text, txtCaid.Text, int.Parse(ddlLP.SelectedValue)))
                                    {
                                        JsHelper.Alert("该客户处在保护期内", this);
                                        return;
                                    }
                                }
                                else
                                {
                                    if (new BLL.CustomerAction().Existsphoto(txtName.Text, txtPhone.Text, int.Parse(ddlLP.SelectedValue)))
                                    {
                                        JsHelper.Alert("该客户还处在保护期内", this);
                                        return;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (txtCaid.Text != "" && txtPhone.Text != "")
                        {
                            if (new BLL.CustomerAction().Exists(txtPhone.Text, txtCaid.Text, int.Parse(ddlLP.SelectedValue)))
                            {
                                JsHelper.Alert("手机号码或身份证已注册!", this);
                                return;
                            }
                        }
                        else
                        {
                            if (new BLL.CustomerAction().Existsphoto(txtName.Text, txtPhone.Text, int.Parse(ddlLP.SelectedValue)))
                            {
                                JsHelper.Alert("客户姓名或手机号码已注册!", this);
                                return;
                            }
                        }
                    }
                    //新增
                    model.Type = 1;
                    Random r = new Random();
                    int i = r.Next(1000, 9999);
                    string left = DateTime.Now.ToString("yyyyMMddhhmmss");
                    string unity = left + i;
                    model.Unity = unity;
                    model.Startime = Convert.ToDateTime(DateTime.Now.ToString());
                    int sj = int.Parse(lbNum.Text);
                    model.Stoptime = Convert.ToDateTime(DateTime.Now.AddDays(sj));
                    model.Title = txtName.Text.Trim();
                    model.Userid = Guid.Parse(Request.Cookies["loginInfo"]["UserId"]);
                    model.Inum = txtCaid.Text.Trim();
                    model.Contenttitle = txtContent.Text.Trim();
                    if (ddlRel.SelectedValue == "其他")
                    {
                        model.Relation = txtRel1.Text;
                    }
                    else
                    {
                        model.Relation = ddlRel.SelectedValue;
                    }
                    model.Relationtitle = txtRelName.Text.Trim();
                    model.RelationPhoto = txtRelPhone.Text.Trim();
                    model.Photo = txtPhone.Text.Trim();
                    model.Lid = Convert.ToInt32(ddlLP.SelectedValue);
                    model.Did = 0;
                    string addName = Request.Cookies["loginInfo"]["UserName"];
                    model.Addname = addName;
                    model.Agentid = int.Parse(Request.Cookies["loginInfo"]["AgencyId"]);
                    model.Addtime = DateTime.Now;
                    model.Typeid = 1;
                    model.Type1 = 1;
                    if (new BLL.CustomerAction().Add(model))
                    {
                        JsHelper.AlertAndRedirect("新增成功!", "protectList.aspx");
                    }
                    else
                    {
                        Maticsoft.Common.MessageBox.Show(this, "新增失败!");
                    }
                }
            }

            protected void btnReset_Click(object sender, EventArgs e)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["upid"]))
                {
                    Response.Redirect(Request.Url.ToString());
                }
                else
                {
                    txtCaid.Text = "";
                    txtContent.Text = "";
                    txtName.Text = "";
                    txtPhone.Text = "";
                    txtRel1.Text = "";
                    txtRelName.Text = "";
                    txtRelPhone.Text = "";
                    ddlLP.SelectedIndex = 0;
                    ddlRel.SelectedIndex = 0;
                }
            }

            protected void ddlLP_SelectedIndexChanged(object sender, EventArgs e)
            {
                string value = ddlLP.SelectedItem.Text;
                if (ddlLP.SelectedValue == "请选择")
                {
                    lbNum.Text = "0";
                    ltlT.Visible = true;
                }
                else
                {
                    Model.LoupanInfo lp = new Model.LoupanInfo();
                    lp = new BLL.LoupanAction().GetModelByLp(value);
                    if (string.IsNullOrEmpty(lp.Numberday.ToString()))
                    {
                        lbNum.Text = "15";
                    }
                    else if (lp.Numberday == 0)
                    {
                        lbNum.Text = "15";
                    }
                    else
                    {
                        lbNum.Text = lp.Numberday.ToString();
                        ltlT.Visible = true;
                    }
                }
            }
        }

    2012年7月14日 0:41
  •  string upId = Request.QueryString["upid"];

    这段代码你能取到值吗?


    windows live Id :hellohongfu@hotmail.com

    2012年7月15日 9:36
  • 你应该一点一点定位,把运行有问题的代码贴出来

    比如一个方法,参数,输入值,输出值


    windows live Id :hellohongfu@hotmail.com

    2012年7月15日 9:38