I have the followig code: - set conn=Server.CreateObject("ADODB.Connection")
-
conn.Provider=provider
-
conn.Open dbpath
-
set rs = Server.CreateObject("ADODB.recordset")
-
-
...
-
-
-
sql="SELECT department, job, start, [end] FROM Qry_AssignedWeek WHERE employee='" & employee & "' ORDER BY start"
-
rs.open sql, conn, sunday
Where the Qry_AssignedWeek is the following query in Access2003: - PARAMETERS sunday DateTime;
-
SELECT *
-
FROM Qry_AssignedNotCancelled
-
WHERE (((Qry_AssignedNotCancelled.start) Between [sunday] And [sunday]+7)) OR (((Qry_AssignedNotCancelled.end) Between [sunday] And [sunday]+7));
this code generates the ASP error:
Provider (0x80020005)
Type mismatch.
/schedule/ViewMyShifts.asp, line 70
The "sunday" variable is a string representing a date in format "dd/mm/yyyy"
I have tried to change the "sunday" in "rs.open sql, conn, sunday" with many different options:
int(sunday)
CDate(sunday)
#23/09/2007#
etc.
All returning various errors.
Please, can anyone guide me around this problem?
2 6078
You could try something like this... and scrap the msAccess query all together.
This would calculate when sunday is, and return all records which fall within the last sunday to the next sunday. In the case of this week, as an example, it would return all records from Sunday the 15th of september to Sunday the 22nd of september. -
If WeekDay(Date()) = 1 Then 'it's sunday
-
dDateStart = Date() ' it's sunday today so we want to start from today's date
-
Else
-
'Today is not sunday, so we need to find when sunday is. To do this, we'll find the integer value of the weekday, and count backwards to sunday.
-
'If today is friday weekDay will return 6 - sunday would be 5 days ago. So weekday*-1 = -6 + 1 = -5
-
iDateChange = (WeekDay(Date())*-1)+1
-
dDateStart = DateAdd(d,iDateChange,Date())
-
End If
-
'Now we have our start date, we just need our end date, which is easy
-
-
dDateEnd = DateAdd(d,7,dDateStart)
-
-
sSQL="SELECT department, job, start, datefield FROM yourtable WHERE employee='" & employee & "' AND datefield BETWEEN " & dDateStart& " AND " & dDateEnd & " ORDER BY datefield"
-
rs.open sql, conn, 3, 3
-
-
I also don't know why you have rs.open sql, conn, sunday
You can't pass a variable through your recordset opening statement. This statement accepts: your sql query, the connection string to your db, and your vb constants. (adReadOnly, adLockOptomistic, etc)
Hope this helps,
Sincerely
Mark
I have the followig code: - set conn=Server.CreateObject("ADODB.Connection")
-
conn.Provider=provider
-
conn.Open dbpath
-
set rs = Server.CreateObject("ADODB.recordset")
-
-
...
-
-
-
sql="SELECT department, job, start, [end] FROM Qry_AssignedWeek WHERE employee='" & employee & "' ORDER BY start"
-
rs.open sql, conn, sunday
Where the Qry_AssignedWeek is the following query in Access2003: - PARAMETERS sunday DateTime;
-
SELECT *
-
FROM Qry_AssignedNotCancelled
-
WHERE (((Qry_AssignedNotCancelled.start) Between [sunday] And [sunday]+7)) OR (((Qry_AssignedNotCancelled.end) Between [sunday] And [sunday]+7));
this code generates the ASP error:
Provider (0x80020005)
Type mismatch.
/schedule/ViewMyShifts.asp, line 70
The "sunday" variable is a string representing a date in format "dd/mm/yyyy"
I have tried to change the "sunday" in "rs.open sql, conn, sunday" with many different options:
int(sunday)
CDate(sunday)
#23/09/2007#
etc.
All returning various errors.
Please, can anyone guide me around this problem?
Thanks! it's working: - sunday = CDate(sunday)
-
sql="SELECT department, job, start, [end] FROM Qry_AssignedNotCancelled WHERE employee='"
-
sql=sql & employee & "' " & "AND start BETWEEN #" & sunday & "# AND #" & sunday + 7 & "#"
-
-
rs.open sql, conn
(the varaiable "sunday" is given as a string "dd/mm/yyyy")
But I am still quite puzzled...
Is there a way to run an Access parameterized query from ASP?
You could try something like this... and scrap the msAccess query all together.
This would calculate when sunday is, and return all records which fall within the last sunday to the next sunday. In the case of this week, as an example, it would return all records from Sunday the 15th of september to Sunday the 22nd of september. -
If WeekDay(Date()) = 1 Then 'it's sunday
-
dDateStart = Date() ' it's sunday today so we want to start from today's date
-
Else
-
'Today is not sunday, so we need to find when sunday is. To do this, we'll find the integer value of the weekday, and count backwards to sunday.
-
'If today is friday weekDay will return 6 - sunday would be 5 days ago. So weekday*-1 = -6 + 1 = -5
-
iDateChange = (WeekDay(Date())*-1)+1
-
dDateStart = DateAdd(d,iDateChange,Date())
-
End If
-
'Now we have our start date, we just need our end date, which is easy
-
-
dDateEnd = DateAdd(d,7,dDateStart)
-
-
sSQL="SELECT department, job, start, datefield FROM yourtable WHERE employee='" & employee & "' AND datefield BETWEEN " & dDateStart& " AND " & dDateEnd & " ORDER BY datefield"
-
rs.open sql, conn, 3, 3
-
-
I also don't know why you have rs.open sql, conn, sunday
You can't pass a variable through your recordset opening statement. This statement accepts: your sql query, the connection string to your db, and your vb constants. (adReadOnly, adLockOptomistic, etc)
Hope this helps,
Sincerely
Mark
Sign in to post your reply or Sign up for a free account.
Similar topics
by: zlatko |
last post by:
There is a form in an Access Project (.adp, Access front end with SQL
Server) for entering data into a table for temporary storing. Then, by
clicking a botton, several action stored procedures...
|
by: Michael DeLawter |
last post by:
Using Access 2002.
I have a chart in a report that is currently based on a query in which
the user enters the start and end date for the chart to display. Both
the start and end dates have been...
|
by: Kenneth |
last post by:
I have a Query that consist of a lot of different sales data, and one of the
colums are different date. The date goes from 1jan2003 til 31jan2003. in
this Query I only want the salesdata for...
|
by: Nicolae Fieraru |
last post by:
Hi All,
I have a table tblProducts where I have four fields:\
Index, ProductName, EnterDate (as Date/Time - Medium Date), PurchaseDate
(Date/Time - Medium Date)
The EnterDate is automatically...
|
by: Tony |
last post by:
Hey guys,
I use Google Groups quite a bit as it is an enormous wealth of
information, and now I need some help. I have created a query using
parameters to capture a range of date, the date is...
|
by: Tony |
last post by:
Hello everyone,
Okay so here is my pickle! I have a field called ARCH_DATE within a
table which has a date stored like "9/1/2004 23:50:00". What I would
like to do is create a date range which...
|
by: Zlatko Matić |
last post by:
Hi everybody!
Recently I was struggling with client/server issues in MS Access/PostgreSQL
combination.
Although Access is intuitive and easy to use desktop database solution, many
problems...
|
by: Julie Wardlow |
last post by:
Help!
I am calculating a future date using the DateAdd function in a query (the
calculation also involves an IIf statement), and have managed to get this
formula to produce the required result....
|
by: ShadesOfGrey |
last post by:
Hello again. Thanks to Gord, I have this cool query that puts my
student attendance records in a calendar format in Access 2003.
PARAMETERS Text ( 255 ), IEEEDouble;
TRANSFORM...
|
by: Fred's |
last post by:
Hi Folks,
I have a report which the record source is a query name: Query3 and in
my Query3 I have this parameter "between And ".
Therefore, when I open my report, it will ask for a Start Date...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
| |