12 Replies - 2788 Views - Last Post: 21 November 2002 - 02:13 AM Rate Topic: -----

#1 sva  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 14-June 02

Help

Posted 16 November 2002 - 06:39 PM

i don't know if this is the right place but im trying to set up a simple blog system, and i want the user to see the blog for the current date, instead of just the last posted one.

so what i decided to do was create a table for every date, but i need some way to display the data from the current date's table.

did any of that make sense?

AE: i should say i want to do this in asp, which really means that it should be in the asp forum...

Is This A Good Question/Topic? 0
  • +

Replies To: Help

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Help

Posted 16 November 2002 - 09:42 PM

Hmm..I may be able to help if you explain a little more. Right now, I don't see why you wouldn't use one table, and have a date field. Then you just pull up the information by date.
SELECT * FROM database where date_field = " & NOW


I'm sure I'm missing something from your explanation. Please tell a little more, and I'm sure that we can get the results you want.
Was This Post Helpful? 0
  • +
  • -

#3 sva  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 14-June 02

Re: Help

Posted 17 November 2002 - 10:07 AM

okay, i'll try and explain a bit better :)

what i've currently got is one table (blogs) and this code just pulling out all the current fields and displaying them
<%
Set MyConn = Server.CreateObject("ADODB.Connection")
MdbFilePath = Server.MapPath("database/data.adb")
MyConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & MdbFilePath & ";"
SQL_query = "SELECT * FROM blog"
Set RS = MyConn.Execute(SQL_query)
WHILE NOT RS.EOF
%>
<%=RS("entry_title")%>&nbsp;[<%=RS("entry_date")%> @ <%=RS("entry_time")%>]<br>
<%=RS("entry_body")%>
<%
RS.MoveNext
WEND
%>
but that just displayes all the entries, but i want it to only display the entry for todays date, so if the date is 17/11/2002 i want it to display only that entry, and i also want a function whereby you can select a date out of a calendar and view the entry for the selected date.

im very new to asp, and i hope that explains it a bit better.
Was This Post Helpful? 0
  • +
  • -

#4 klewlis  Icon User is offline

  • cur tu me vexas?

Reputation: 8
  • View blog
  • Posts: 1,723
  • Joined: 09-November 01

Re: Help

Posted 17 November 2002 - 05:28 PM

yep you just have to modify your select statement.

So:

SQL_query = "SELECT * FROM blog WHERE entry_date = " & Date()



That will give you today's date. If you want other dates, you can just use a variable and stick it in there instead.
Was This Post Helpful? 0
  • +
  • -

#5 sva  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 14-June 02

Re: Help

Posted 17 November 2002 - 06:12 PM

thank's :)
Was This Post Helpful? 0
  • +
  • -

#6 sva  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 14-June 02

Re: Help

Posted 19 November 2002 - 12:19 PM

okay, now i've got this code, which is the same as before but with the Date() thing added
<%
Set MyConn = Server.CreateObject("ADODB.Connection")
MdbFilePath = Server.MapPath("database/data.adb")
MyConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & MdbFilePath & ";"
SQL_query = "SELECT * FROM blog WHERE entry_date = "& Date() 
Set RS = MyConn.Execute(SQL_query)
WHILE NOT RS.EOF
%>
<div id="blog_under" style="border-bottom: 1px dashed #dddddd"><%=RS("entry_title")%> :: <%=RS("entry_date")%></div><br>
<%=RS("entry_body")%><br>
<%
RS.MoveNext
WEND
%>


and all im getting is a blank screen, and i know for a fact that i've got an netry for that date in my database and i've tried setting the date field in the databses to a date value and character and i still get a blank screen, what's going on?
Was This Post Helpful? 0
  • +
  • -

#7 klewlis  Icon User is offline

  • cur tu me vexas?

Reputation: 8
  • View blog
  • Posts: 1,723
  • Joined: 09-November 01

Re: Help

Posted 19 November 2002 - 12:47 PM

check that your date formats are the same. Access tends to format things differently. Make sure that the format you're putting in matches the format that's in there (yy-mm-dd or yyyy-mm-dd or mm-dd-yyyy etc).
Was This Post Helpful? 0
  • +
  • -

#8 sva  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 14-June 02

Re: Help

Posted 19 November 2002 - 03:20 PM

i've tried every date combination imaginable, and i still get get nothing.
Was This Post Helpful? 0
  • +
  • -

#9 klewlis  Icon User is offline

  • cur tu me vexas?

Reputation: 8
  • View blog
  • Posts: 1,723
  • Joined: 09-November 01

Re: Help

Posted 19 November 2002 - 05:36 PM

and it works without the WHERE clause?

if it's just the date that's not matching up, then I don't have any other suggestions, other than the date formats. Maybe someone else around here can help....
Was This Post Helpful? 0
  • +
  • -

#10 sva  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 14-June 02

Re: Help

Posted 19 November 2002 - 05:42 PM

yep, it works witthout the where bit.
Was This Post Helpful? 0
  • +
  • -

#11 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Help

Posted 19 November 2002 - 08:58 PM

Hmmm....Couple of things to try or look for.
1. Print out your SQL statement, make sure it's got the right info.
2. Print out the number of recordsets being returned
3. Make sure no close tags are missing if you're using an older Netscape
4. Try "SELECT * FROM blog WHERE entry_date = #" & Date() & "#"
If not, let me know, I'll run your code and see if I can debug.
Was This Post Helpful? 0
  • +
  • -

#12 sva  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 14-June 02

Re: Help

Posted 20 November 2002 - 01:56 PM

Quote

1. Print out your SQL statement, make sure it's got the right info.

you mean print it here?
SQL_query = "SELECT * FROM blog WHERE entry_date = "& Date()


Quote

2. Print out the number of recordsets being returned

i've no idea how to do that, im very new to asp and databases

Quote

4. Try "SELECT * FROM blog WHERE entry_date = #" & Date() & "#"

i still get the same blank screen, but it will display if i put the date in manualy...
SQL_query = "SELECT * FROM blog WHERE entry_date = DateValue('20/11/02')"

Was This Post Helpful? 0
  • +
  • -

#13 gheaven  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 13-September 02

Re: Help

Posted 21 November 2002 - 02:13 AM

I trust that you have got your SQL working by now, but just in case..

1. SQL commands are passed as text. ASP (VB) does an implicit date conversion based on your machine's locale. This means it could be dd/mm/yyyy or mm/dd/yyyy depending on where you are in the world. This is generally bad. You have to explictly convert all dates into an unambiguous date format when assembling these sorts of strings within ASP. Most of us have our own date libararies for this purpose. Also it is better and faster to also convert the date explicitly in the SQL string (i.e. use # # delimiters or a cdate() function call).

2. I note that you are using Access as the database. This will be OK for single user ASP apps but the access engine doest not thread properly and with multiple users you can get the situation where the web server "loses" the database. You need a real database engine (SQL Server/Oracle) to make ASP apps robust.

regards.
Gary
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1