IIS ASP - Re: Error in this statement-->sqlSELsite = "SELECT Name FROM tblbwday WHERE B'

This is Interesting: Free IT Magazines  
Home > Archive > IIS ASP > July 2006 > Re: Error in this statement-->sqlSELsite = "SELECT Name FROM tblbwday WHERE B'





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: Error in this statement-->sqlSELsite = "SELECT Name FROM tblbwday WHERE B'
divya

2006-07-31, 1:23 pm

Hi
I changed the code to this

<%set objConn =server.createobject("ADODB.connection")
objConn.open "DSN=Photo"
Dim sqlSELsite,ObjRS
sqlSELsite = "SELECT * FROM tblbwday "
Set ObjRS = Server.CreateObject("ADODB.Recordset")
ObjRS.Open sqlSELsite,objConn
Do While Not ObjRS.EOF
If Datepart("y",objRS("B'day")) =DatePart("y",now) then
Response.Write objRS("Name")
Response.Write "<BR>"
End If
objRS.MoveNext
Loop
%>

this works.

but I want to know if I want to use the date function inside the Sql
query how do I do?

sqlSELsite = "SELECT Name FROM tblbwday WHERE B'day =#"& date() &"# "
This doesn't work.Plz tell me.
Regards
Divya


divya wrote:
> Hi,
> I have a table tblbwday with 2 fields Name and Birthday.I have written
> this script for displaying evryday names of the people on that day.
>
> <%
> set objConn =server.createobject("ADODB.connection")
> objConn.open "DSN=Photo"
> Dim sqlSELsite,ObjRSSel
>
> sqlSELsite = "SELECT Name FROM tblbwday WHERE B'day ="& date() &" " '
> Error in this line
> Set ObjRSSel = Server.CreateObject("ADODB.Recordset")
> ObjRSSel.Open sqlSELsite,objConn
> Do While Not objRS.EOF
> Response.Write "Name: " &objRSel("Name")
> Response.Write "<P><HR><P>"
> objRSel.MoveNext
> Loop
> %>
> Error is:-
>
> Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
> [Microsoft][ODBC Microsoft Access Driver] Syntax error in string in
> query expression 'B'day =7/31/2006'.
> /Project1_Local/ASP Page4.asp, line 15
>
> I have added a record with today's date in the table.I know this logic
> is wrong we need to compare only day and month.and this will compare
> year also.Plz send me some tips which can help me in comparing only day
> and month.
> intDays = DatePart("y",now) will give me the curent day in the year.Can
> I compare intdays with the b'day's in the table?
>
> Regards
> Divya


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com