Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problems selecting records

Problems selecting records

Scheduled Pinned Locked Moved ASP.NET
databasesysadminhelpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Muntyness
    wrote on last edited by
    #1

    Hi, I'm having a problem selecting records from my database to display on the web page. I want to select all records with a specific name, and on a specific date. The code I'm using looks like this: StrConnect = Server.MapPath("./MyDataBase.mdb") cn = Server.CreateObject("ADODB.Connection") cn.Open("PROVIDER=MICROSOFT.JET.OLEDB.4.0;Data Source =" & StrConnect) rs = Server.CreateObject("ADODB.Recordset") rs.Open("SELECT * FROM TheLog WHERE name='123' AND recdate=#01/02/2003#", cn, 3) Now despite there being about 5 records with that name and date, I don't get any records returned. Does anyone know why? P.S. The database is a Access database, the name field is set to "Text" and the recdate field is set to "Date/Time" - Munty

    M B 2 Replies Last reply
    0
    • M Muntyness

      Hi, I'm having a problem selecting records from my database to display on the web page. I want to select all records with a specific name, and on a specific date. The code I'm using looks like this: StrConnect = Server.MapPath("./MyDataBase.mdb") cn = Server.CreateObject("ADODB.Connection") cn.Open("PROVIDER=MICROSOFT.JET.OLEDB.4.0;Data Source =" & StrConnect) rs = Server.CreateObject("ADODB.Recordset") rs.Open("SELECT * FROM TheLog WHERE name='123' AND recdate=#01/02/2003#", cn, 3) Now despite there being about 5 records with that name and date, I don't get any records returned. Does anyone know why? P.S. The database is a Access database, the name field is set to "Text" and the recdate field is set to "Date/Time" - Munty

      M Offline
      M Offline
      MatthysDT
      wrote on last edited by
      #2

      Try using a range of dates (eg. between 01/02/2003 00:00:00 and 01/02/2003 23:59:59, don't use my syntax ) rather than specifying recdate to be exactly equal to 01/02/2003

      _______________________________________________________________________ http://www.readytogiveup.com/[^] "you can't forget something you never knew..." M. Du Toit

      M 1 Reply Last reply
      0
      • M MatthysDT

        Try using a range of dates (eg. between 01/02/2003 00:00:00 and 01/02/2003 23:59:59, don't use my syntax ) rather than specifying recdate to be exactly equal to 01/02/2003

        _______________________________________________________________________ http://www.readytogiveup.com/[^] "you can't forget something you never knew..." M. Du Toit

        M Offline
        M Offline
        Muntyness
        wrote on last edited by
        #3

        Nope, didn't work. :/ The string I used was: SELECT * FROM TheLog WHERE name='123' AND recdate BETWEEN #01/02/2003 00:00:00# AND #01/02/2003 23:59:59# Also,just to note, when I ouput the date field to a text box, I get: 01/02/2003 - Munty

        1 Reply Last reply
        0
        • M Muntyness

          Hi, I'm having a problem selecting records from my database to display on the web page. I want to select all records with a specific name, and on a specific date. The code I'm using looks like this: StrConnect = Server.MapPath("./MyDataBase.mdb") cn = Server.CreateObject("ADODB.Connection") cn.Open("PROVIDER=MICROSOFT.JET.OLEDB.4.0;Data Source =" & StrConnect) rs = Server.CreateObject("ADODB.Recordset") rs.Open("SELECT * FROM TheLog WHERE name='123' AND recdate=#01/02/2003#", cn, 3) Now despite there being about 5 records with that name and date, I don't get any records returned. Does anyone know why? P.S. The database is a Access database, the name field is set to "Text" and the recdate field is set to "Date/Time" - Munty

          B Offline
          B Offline
          Blue_Boy
          wrote on last edited by
          #4

          name is reserved word in TSQL

          Muntyness wrote:

          WHERE name='123'

          and you try this "SELECT * FROM TheLog WHERE [name]='123' AND recdate=#01/02/2003#"


          I Love SQL

          M 1 Reply Last reply
          0
          • B Blue_Boy

            name is reserved word in TSQL

            Muntyness wrote:

            WHERE name='123'

            and you try this "SELECT * FROM TheLog WHERE [name]='123' AND recdate=#01/02/2003#"


            I Love SQL

            M Offline
            M Offline
            Muntyness
            wrote on last edited by
            #5

            Name is reserved? Bah. Well I've changed the field to Job now. and I've tried both: "SELECT * FROM TheLog WHERE job='123' AND recdate=#01/02/2003#" And "SELECT * FROM TheLog WHERE [job]='123' AND recdate=#01/02/2003#" Neither of them work. This does work however: "SELECT * FROM TheLog WHERE job='123'" - Munty

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups