473,395 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Error in this statement-->sqlSELsite = "SELECT Name FROM tblbwday WHERE B'day ="& date() &""

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

Jul 31 '06 #1
3 3062
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
Jul 31 '06 #2
Your prblem stems from the use of B'day as a field name. The
apostrophe makes ADO think it has come to the begining of a text value
in an SQL statement. Change the field name to get rid of the
apostrophe.

Don't use SELECT *. It is poor practice, and returns more data than
you probably need. The reason it works for you here is you didn't name
B'day in your select statement.

sqlSELsite = "SELECT Name FROM tblbwday WHERE Bday = Date()" should do
it.

Something to consider: You are using an outdated, deprecated,
inefficient DSN and the ODBC drivers to connect to your database. You
should use the native OLEDB driver instead.

http://www.aspfaq.com/show.asp?id=2126

This is nothing to do with your problem, but should help generally in
future

--
Mike Brind

divya wrote:
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
Jul 31 '06 #3
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"
Nothing to do with your problem, but you should stop using DSN's:
http://www.aspfaq.com/show.asp?id=2126
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?
You've got several problems:

1. The use of nonstandard characters in your field names. "B'Day"???
What's wrong with BDay, or even BirthDay?
If you can't change the name of this field (and you really should), you
are going to need to surround it with brackets when using it in queries
called by ADO:
[B'Day]

2. Is [B'Day] a Date/Time field? If so, it does not store just the date:
it stores both date and time. If no time is entered, thhen it defaults
to midnight. Dates are stored as Double numbers, with the integer
portion representing the number of days since the seed date, and the
decimal portion represnting the time of day (.0=midnight, .5 = noon)

Given that it's a date/time field this will work:

sqlSELsite =" ... WHERE [B'Day] >= Date() AND " & _
"[B'Day] < dateadd(1,'d',Date())"

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 31 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jim | last post by:
Im trying to find the error in this statement: CREATE PROCEDURE STP_selectmain AS select a.inventoryid, b.firstname, b.lastname, art.title, art.medium, a.cost, a.inventoryid,...
1
by: steven virnig | last post by:
We have an application group that wants to pull date from SQL Server and write it to text file on the server. They want the file format to be 12100_YYYMMDDHHMM.fr1 for one set of data,...
10
by: WindAndWaves | last post by:
Hi Gurus Whenever I start making changes in VB (without having anything open), the first time after opening the application, i will get the following error: This will reset your project do you...
6
by: ashok.dhananjeyan | last post by:
Hi, Actually , I wrote one javascript to retrieve the name of the form in one particular page. what i did in this page is, <script> function checkbutton() {
5
by: aspineux | last post by:
I want to parse 'foo@bare' or '<foot@bar>' and get the email address foo@bar the regex is r'<\w+@\w+>|\w+@\w+' now, I want to give it a name
13
by: ogo796 | last post by:
hi everyone i upload file each an every day so i want to keep track of how many files i uploade a day by creating new directory everytime when i uploade base on the system date. example the new...
3
by: ChipR | last post by:
I'm using strFileName = "\\serverName\folderName\fileName.txt" If Dir(strFileName) > "" Then ... This worked fine for me, even when I disconnected from the network, but when a user ran it on...
3
by: Daved Nconfused | last post by:
I found this code and would like to make it so that if a person is checking availability for something, when the correct date is selected, it goes to a URL. Example, click DEC. 18 2010 and it goes...
1
by: Harshini Raj | last post by:
Hi, I am unable to fix this error. Canyou tell me what compiler options i have to use to fix this issue? Issue Error 40:Undeclared identifier 'Name' -- Within an expression, an identifier was...
3
by: mahmoodn | last post by:
Hi, I have a struct with this definition struct SeverityAction : public Action { uint32_t theSeverity; //***** public: SeverityAction(uint32_t aSeverity); ... };
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.