ASP Date Question (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


chadb -> ASP Date Question (2/4/2008 9:48:03)

I have 2 questions. I have a Access database, which has a table with a row called Date. I am trying to query using this:

Mydate = date()
str1 = "SELECT * FROM Birthdays where Date = " & MyDate

First questions is: This does not return anything, I have confirmed O do have a date match, second, What do I need to add to not show an error if there is not a match? I have tried this, but then it just tries to load the page and never finishes, or it takes a long time.

While Not MyRs.Eof

Thanks




rdouglass -> RE: ASP Date Question (2/4/2008 10:46:15)

quote:

str1 = "SELECT * FROM Birthdays where Date = " & MyDate


Is the Date field a true Date/Time field? If SO, try this for Access DB:

str1 = "SELECT * FROM Birthdays where [Date] = #" & MyDate & "#"

and this for SQL server:

str1 = "SELECT * FROM Birthdays where [Date] = '" & MyDate & "'" (see the apostrophes?)

Se the [, ], #, and ' stuff? Time/Dates are delimited by # in Access and ' in many other SQL engines (MS SQL, mySQL, etc.)

That help any?




chadb -> RE: ASP Date Question (2/4/2008 10:50:00)

Yes, that is it. What should I do if it does not find a match? I want it to not give an error.




rdouglass -> RE: ASP Date Question (2/4/2008 13:31:22)

quote:

I want it to not give an error.


What kind of error and where in the code / what line # does it report?




chadb -> RE: ASP Date Question (2/4/2008 14:43:31)

ADODB.Field error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

/Performance/defaultinwork.asp, line 29


Line 29 is:
bdname = MyRS("Name")




rdouglass -> RE: ASP Date Question (2/4/2008 15:35:26)

quote:

bdname = MyRS("Name")


Is that 'inside' the section that begins with this:

While Not MyRs.Eof

Does that make any sense? IOW, is it inside the section where we're sure we have a result as in "While Not MyRs.Eof "?




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
4.785156E-02