473,581 Members | 2,757 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.createo bject("ADODB.co nnection")
objConn.open "DSN=Photo"
Dim sqlSELsite,ObjR SSel

sqlSELsite = "SELECT Name FROM tblbwday WHERE B'day ="& date() &" " '
Error in this line
Set ObjRSSel = Server.CreateOb ject("ADODB.Rec ordset")
ObjRSSel.Open sqlSELsite,objC onn
Do While Not objRS.EOF
Response.Write "Name: " &objRSel("Name" )
Response.Write "<P><HR><P> "
objRSel.MoveNex t
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",no w) 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 3081
Hi
I changed the code to this

<%set objConn =server.createo bject("ADODB.co nnection")
objConn.open "DSN=Photo"
Dim sqlSELsite,ObjR S
sqlSELsite = "SELECT * FROM tblbwday "
Set ObjRS = Server.CreateOb ject("ADODB.Rec ordset")
ObjRS.Open sqlSELsite,objC onn
Do While Not ObjRS.EOF
If Datepart("y",ob jRS("B'day")) =DatePart("y",n ow) 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.createo bject("ADODB.co nnection")
objConn.open "DSN=Photo"
Dim sqlSELsite,ObjR SSel

sqlSELsite = "SELECT Name FROM tblbwday WHERE B'day ="& date() &" " '
Error in this line
Set ObjRSSel = Server.CreateOb ject("ADODB.Rec ordset")
ObjRSSel.Open sqlSELsite,objC onn
Do While Not objRS.EOF
Response.Write "Name: " &objRSel("Name" )
Response.Write "<P><HR><P> "
objRSel.MoveNex t
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",no w) 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.createo bject("ADODB.co nnection")
objConn.open "DSN=Photo"
Dim sqlSELsite,ObjR S
sqlSELsite = "SELECT * FROM tblbwday "
Set ObjRS = Server.CreateOb ject("ADODB.Rec ordset")
ObjRS.Open sqlSELsite,objC onn
Do While Not ObjRS.EOF
If Datepart("y",ob jRS("B'day")) =DatePart("y",n ow) 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.createo bject("ADODB.co nnection")
objConn.open "DSN=Photo"
Dim sqlSELsite,ObjR SSel

sqlSELsite = "SELECT Name FROM tblbwday WHERE B'day ="& date() &" " '
Error in this line
Set ObjRSSel = Server.CreateOb ject("ADODB.Rec ordset")
ObjRSSel.Open sqlSELsite,objC onn
Do While Not objRS.EOF
Response.Write "Name: " &objRSel("Name" )
Response.Write "<P><HR><P> "
objRSel.MoveNex t
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",no w) 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.createo bject("ADODB.co nnection")
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,ObjR SSel

sqlSELsite = "SELECT Name FROM tblbwday WHERE B'day ="& date() &" " '
Error in this line
Set ObjRSSel = Server.CreateOb ject("ADODB.Rec ordset")
ObjRSSel.Open sqlSELsite,objC onn
Do While Not objRS.EOF
Response.Write "Name: " &objRSel("Name" )
Response.Write "<P><HR><P> "
objRSel.MoveNex t
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",no w) 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',D ate())"

--
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
7209
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, a.receivedate, a.dimensions, a.reference, art.provenance, sum(c.restorationcost),
1
4422
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, 12100_YYYMMDDHHMM.fr2 for a second set...and so on. The '12100' is fixed, but the rest of the file name will always have to include the system date/time. Is...
10
3319
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 want to proceed anyway? Why would I get this??? I just have no idea.
6
3862
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
3791
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
6614
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 directory must be name according to the system date: $newdir = "system date"; i want my directory name to look like 30January2007 i will be...
3
29567
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 an unconnected laptop the Dir line threw an Error 52: Bad file name or number. It seems like Dir should just return an empty string instead of an...
3
2835
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 to one URL, Dec.19 2010 and it goes to another. or Dec. 18 2011 and it goes to another. I dont understand how to correlate all that. any help would...
1
4985
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 encountered that had not previously been declared and was not followed by a left parenthesis. Name is the name of the identifier.
3
18221
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
7876
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8156
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8310
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7910
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8180
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2307
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1144
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.