Results 1 to 4 of 4

Thread: Problem with a DA class

Threaded View

  1. #1

    Thread Starter
    Addicted Member ddmeightball's Avatar
    Join Date
    Nov 2004
    Location
    Nebraska
    Posts
    183

    Problem with a DA class

    I am having a problem with a DA class that I am writing. My problem seems to be stemming from when I try to put a date object into an Access database datetime field.

    I believe it is a problem with my insert sql statement. Here it is.

    Code:
    		String sql = "INSERT INTO SECTIONS(course_number, section_number, instructor_id, days, start_time, end_time, begin_date, end_date, room_number) values(" 
    		+ "'" + s.getCourseNum() + "'" + "," 
    		+	    s.getSectionNum() + "," 
    		+ "'" + s.getInstrutorID()+"'" + "," 
    		+ "'" + s.getDays() + "'" + "," 
    		+ "#" + s.getBeginTime().getTime().getMonth() + "/" + s.getBeginTime().getTime().getDate() + "/"  + s.getBeginTime().getTime().getYear()+  "#" + ","
    		+ "#" + s.getEndTime().getTime().getMonth() + "/" + s.getEndTime().getTime().getDate() + "/"  + s.getEndTime().getTime().getYear()+  "#" + ","
    		+ "#" + s.getStartDate().getTime().getMonth() + "/" + s.getStartDate().getTime().getDate() + "/"  + s.getStartDate().getTime().getYear()+  "#" + ","
    		+ "#" + s.getEndDate().getTime().getMonth() + "/" + s.getEndDate().getTime().getDate() + "/"  + s.getEndDate().getTime().getYear()+  "#" + ","
    		+ "'" + s.getRoomNum() + "'" + ")";
    My code compiles, but when I try to run it, I am getting an error when I try to run my TestSectionConnection class.

    Problems with query/update : [Microsoft][ODBC Microsoft Access Driver] Syntax error in date in query expression '#11/31/-1898#'.
    Press any key to continue...
    I dont get where it is getting the date 11/31/-1898. It seems like it is getting bad data in part of the date object. Would not setting pieces of the date object when I put it into the database cause this error?

    I have included my section da classes and my Access database in a zip file at the bottom of this post so you can look at it if you want to. I can post the code if you would rather read it here instead of getting it from the zip file. Any input is helpful. THanks
    Attached Files Attached Files
    Otaku no Kamisama – God of the Geeks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width