0

我想在我的 ACCESS DB 中输入一个日期,该字段是日期/时间。用户在此方法中以表格形式输入(文本)DD/MM/YYYY

代码:日期/时间对象

DateTime Bday = new DateTime(long.Parse(Request.Form["Bday"]));

SQL查询:

cmd.CommandText = "INSERT INTO (Fname,Lname,User,Pass,Email,BiDate,IsAdmin,IsMale) VALUES ('" + fname + "','" + lname + "','" + user + "','" + pass + "','" + email + "',#" + Bday + "#," + admin + "," + male + ")";

它不工作

4

1 回答 1

0

卸下long.Parse零件

        DateTime Bday = DateTime.ParseExact(Request.Form["Bday"], "dd/MM/yyyy", 
        CultureInfo.InvariantCulture);

        cmd.CommandText = "INSERT INTO (Fname,Lname,[User],Pass,Email,BiDate,"
        +"IsAdmin,IsMale) " + 
        "VALUES ('" + fname + "','" + lname + "','" + user + "','" + pass + "','"
        + email + "',#" + Bday.ToString("dd/MM/yyyy") + "#," + admin + "," + male + ")";

希望这可以帮助!

于 2013-01-10T15:32:53.047 回答