我的程序在本机上不报错,但是放在台湾的服务器上就会报错 报错是 char转datetime出现错误! 不知道啥子原因!  台湾机子都是繁体字! 有没人能指点下

解决方案 »

  1.   

    char转datetime提示很明显了,你定位下你出错的代码呢 
      

  2.   

    char转datetime出现错误
    ===============
    查看一下数据库,里面的字段datetime是不是有不是时间格式的字符串在里面了
      

  3.   

       protected void Page_Load(object sender, EventArgs e)
        {
            string sql = "select * from Users where id=" + Class.Get_Cookie("User_ID");
            DataTable dt = new SQL().SetDelete(sql).Tables[0];
            if (dt.Rows.Count > 0)
            {
                Label2.Text = dt.Rows[0]["vmoney"].ToString();
            }
            if (!IsPostBack)
            {
                bound();
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text.Trim() != "")
            {
                try
                {
                    string sql = "select * from xuniM where ispay=0 and uid=" + Class.Get_Cookie("User_ID");
                    DataTable dt = new SQL().SetDelete(sql).Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        Class.SetClue_URL("申請為批復,請不要重複申請", "", 0);
                    }
                    else
                    {
                        int m = Convert.ToInt32(TextBox1.Text.Trim());
                        sql = "insert into xuniM values(" + Class.Get_Cookie("User_ID") + ",'" + m + "',0,'1990-06-22')";
                        new SQL().UpDelete(sql);
                        Class.SetClue_URL("申請成功,請等待回覆", "", 0);
                    }
                }
                catch (Exception)
                {                Class.SetClue_URL("請正確填寫充值金額", "", 0);
                }        }
        }
        public void bound()
        {
            try
            {
                string sql = "select * from xuniM where ispay=1 and  uid=" + Class.Get_Cookie("User_ID");
                if (TextBox2.Text.Trim() != "")
                {
                    sql += " and dateSuc>='" + Convert.ToDateTime(TextBox2.Text) + "'";
                }
                else
                {
                    sql += " and dateSuc>='" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "'";
                }
                DataSet ds = new SQL().SetDelete(sql);
                dlUser.DataSource = ds;
                dlUser.DataBind();
            }
            catch (Exception)
            {            Class.SetClue_URL("发生错误","",0);
            }
        }
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            bound();
        }
      

  4.   

       protected void Page_Load(object sender, EventArgs e)
        {
            string sql = "select * from Users where id=" + Class.Get_Cookie("User_ID");
            DataTable dt = new SQL().SetDelete(sql).Tables[0];
            if (dt.Rows.Count > 0)
            {
                Label2.Text = dt.Rows[0]["vmoney"].ToString();
            }
            if (!IsPostBack)
            {
                bound();
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text.Trim() != "")
            {
                try
                {
                    string sql = "select * from xuniM where ispay=0 and uid=" + Class.Get_Cookie("User_ID");
                    DataTable dt = new SQL().SetDelete(sql).Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        Class.SetClue_URL("申請為批復,請不要重複申請", "", 0);
                    }
                    else
                    {
                        int m = Convert.ToInt32(TextBox1.Text.Trim());
                        sql = "insert into xuniM values(" + Class.Get_Cookie("User_ID") + ",'" + m + "',0,'1990-06-22')";
                        new SQL().UpDelete(sql);
                        Class.SetClue_URL("申請成功,請等待回覆", "", 0);
                    }
                }
                catch (Exception)
                {                Class.SetClue_URL("請正確填寫充值金額", "", 0);
                }        }
        }
        public void bound()
        {
            try
            {
                string sql = "select * from xuniM where ispay=1 and  uid=" + Class.Get_Cookie("User_ID");
                if (TextBox2.Text.Trim() != "")
                {
                    sql += " and dateSuc>='" + Convert.ToDateTime(TextBox2.Text) + "'";
                }
                else
                {
                    sql += " and dateSuc>='" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "'";
                }
                DataSet ds = new SQL().SetDelete(sql);
                dlUser.DataSource = ds;
                dlUser.DataBind();
            }
            catch (Exception)
            {            Class.SetClue_URL("发生错误","",0);
            }
        }
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            bound();
        }
      

  5.   

    类似这样写
    Convert.ToDateTime(TextBox2.Text).ToString("yyyy-MM-dd HH:mm:ss")