如标题,我数据库里的日期是2008-10-29在修改信息时读出来的却是:1900-1-1 0:00:00
我的修改代码:
这是修改时间的:
this.TextBox2.Text = access.FindString("select vipstart from userinfos where id="+iid);

解决方案 »

  1.   

    NULL的时候读出来就是1900-1-1 0:00:00 
    看下是不是NULL
      

  2.   

    [code=C#]
    this.TextBox2.Text = access.FindString("select vipstart from userinfos where id="+iid)].ToShortDateString(); 
    [/code
      

  3.   

    FindString这个方法有什么处理?
      

  4.   

    用Split Substring随便那一个截取一下就行
      

  5.   

    access.FindString()贴出这个方法的代码
      

  6.   

     public static string FindString(string sql)
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
            try
            {
                conn.Open();
                SqlCommand sqlcmd = new SqlCommand(sql,conn);
                string hang = Convert.ToString(sqlcmd.ExecuteScalar());
                return hang;
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);        }
            finally
            {
                conn.Close();
            }    }
      

  7.   

    access.FindString("select vipstart from userinfos where id="+iid); 
    看看他的值是什么
    还有
    select vipstart from userinfos where id="+iid 结果集是什么
    红色部分是否打错了
      

  8.   

    SQL 默认时间是1900-1-1 0:00:00 
     你可能是SQL有错误
      

  9.   

    NULL的时候读出来就是1900-1-1 0:00:00 
    看下是不是NULL