我想在我的ACCESS数据库中输入DATE,该字段为DATE / TIME。 用户以此方法(文本)DD / MM / YYYY
的形式输入代码: 日期/时间对象
DateTime Bday = new DateTime(long.Parse(Request.Form["Bday"]));
SQL QUERY:
cmd.CommandText = "INSERT INTO (Fname,Lname,User,Pass,Email,BiDate,IsAdmin,IsMale) VALUES ('" + fname + "','" + lname + "','" + user + "','" + pass + "','" + email + "',#" + Bday + "#," + admin + "," + male + ")";
无效
答案 0 :(得分: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 + ")";
希望这有帮助!