SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist
    Join Date
    Jul 2005
    Posts
    456
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    passing value of a record correctly?

    hi all, this is driving me crazy and this forum is my usual last resort when i cant get something working! im trying to add some data to a table (access db). but first i need to find the primary key id of the fields im about to enter. im dealing with dates here, hence the bits of code concerning dates. so far i have:

    var addMonthFinalArray = new Array
    var addMonthFinalArray2 = new Array
    var z = 0
    var weekInt = 0
    while (z <= Number(Request("selWeeks"))){
    newDayVar = Number(Number(dayVar) + Number(weekInt))
    // split date to american format
    addMonthFinalArray[z] = new Date (monthVar + "/" + newDayVar + "/" + yearVar)
    var rsFindID = Server.CreateObject("ADODB.Recordset");
    rsFindID.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../includes/meditect.mdb");
    rsFindID.Source = "SELECT * FROM tbDates WHERE dateName = #" + formatUKDate(addMonthFinalArray[z]) + "#"
    rsFindID.CursorType = 1;
    rsFindID.CursorLocation = 2;
    rsFindID.LockType = 3;
    rsFindID.Open()
    // passing the recordset object and not the actual value?
    addMonthFinalArray2[z] = rsFindID("dateID")

    Response.write(addMonthFinalArray2[z] + "<br>")
    // CANT GET ID INTO FOLLOWING TABLE?
    /*////////////////////////////
    rsAdd.AddNew()
    rsAdd("clinicID") = Number(Request("clinicID"))
    rsAdd("dateID") = addMonthFinalArray2[z]
    rsAdd("timeID") = Number(Request("selTime"))
    rsAdd.Update()
    //////////////////////////*/
    weekInt += 7
    z ++
    }

    so i can write out addMonthFinalArray2[z], but cant get the value of it into my db. i get an EOF/BOF error. i can hardcode a value on the line:
    rsAdd("dateID") = addMonthFinalArray2[z]
    so it would be
    rsAdd("dateID") = 9
    and that works fine. im thinking: am i pasisng the rcordset object to addMonthFinalArray2 as opposed to the actual value? if i try:
    addMonthFinalArray2[z] = Number(rsFindID("dateID")) i get a bof error. any help would be muchly appreciated. ive nearly got this headache of a site finished, and this is my final hurdle (apart from trying cross domain updating of databases!). many thanks
    - G

  2. #2
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    will this
    Response.write(addMonthFinalArray2[z] + "<br>")
    prints anything?

    -SSJ

  3. #3
    SitePoint Evangelist
    Join Date
    Jul 2005
    Posts
    456
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi SSJ,
    yes, it prints it out fine. thats why i dont undertsand it!? surely if its printing it out ok i can put it in the array ok? 'tis weird.
    - G

  4. #4
    SitePoint Evangelist
    Join Date
    Jul 2005
    Posts
    456
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi, ok, i think its something to do with the date values. im using the uk date (dd/mm/yyyy) format, but turning it into the US date format (mm/dd/yyyy) for access to use. i think this is where the problem is arising.
    im incrmenting the day by 7, but i seem to be getting the follwing when writing the rs source to the page:

    SELECT * FROM tbDates WHERE dateName = #01/02/2007#
    11 0
    SELECT * FROM tbDates WHERE dateName = #01/09/2007#
    7 1
    SELECT * FROM tbDates WHERE dateName = #01/04/2008#
    NaN
    SELECT * FROM tbDates WHERE dateName = #01/11/2008#
    NaN
    SELECT * FROM tbDates WHERE dateName = #01/06/2009#
    NaN
    SELECT * FROM tbDates WHERE dateName = #01/01/2010#
    NaN

    the date jumps from 2007 to 2008 for some reason. any ideas? ill continue looking into it.
    - G

  5. #5
    SitePoint Evangelist
    Join Date
    Jul 2005
    Posts
    456
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, now im writing out uk dates to access. its writing out:
    SELECT * FROM tbDates WHERE dateName = #02/01/2007#
    NaN
    SELECT * FROM tbDates WHERE dateName = #09/01/2007#
    NaN
    SELECT * FROM tbDates WHERE dateName = #16/01/2007#
    387 2
    SELECT * FROM tbDates WHERE dateName = #23/01/2007#
    9 3
    SELECT * FROM tbDates WHERE dateName = #30/01/2007#
    388 4
    SELECT * FROM tbDates WHERE dateName = #06/02/2007#
    NaN


    so when the day isnt a single digit (02, 09 etc...) then access cant find it, when its 2 digits (16, 23 etc...) it finds the date. why is this? im confused!


Bookmarks

Posting Permissions

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