0

ACCESS DB に DATE を入力したいのですが、フィールドは DATE/TIME です。ユーザーは、このメソッドのフォームに入力します (テキスト) DD/MM/YYYY

コード: DATE/TIME オブジェクト

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 に答える