Click to See Complete Forum and Search --> : it's not working...


weee
06-04-2004, 12:44 AM
[Microsoft][ODBC Microsoft Access Driver] Invalid procedure call

for this line:
SQL = "Select id,user,pass,serviceDate FROM tstTBL Where user='" & Request.form("user") & "' and pass='" & Request.form("pass") & "' and DATEDIFF('Dd', serviceEndDate, " & Date() & ") >= 0;"

Why's that?

buntine
06-04-2004, 01:04 AM
Try this. I always screw up this function :p

SQL = "Select id,user,pass,serviceDate FROM tstTBL Where user='" & Request.form("user") & "' and pass='" & Request.form("pass") & "' and DATEDIFF(DAY, serviceEndDate, '" & Date() & "') >= 0;"

Access takes an SQL constant as the first argument apposed to a string.

Regards.

weee
06-04-2004, 01:16 AM
I'm going crazy!

Here's the whole code:

<%
msg = ""

If request.form("pass") <> "" Then
SQL = "Select id,user,pass,serviceDate FROM tstTBL Where user='" & Request.form("user") & "' and pass='" & Request.form("pass") & "' and DATEDIFF(DAY, serviceDate, '" & Date() & "') >= 0;"
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open SQL,DSN,3,1
if NOT rs.EOF Then
id = rs("id")
Session("login") = "True"
rs.Close
Set rs = Nothing
Response.redirect "tst.asp?id=" & id
Response.End
Else
'If rs("serviceEndDate") < DATE() Then
'msg = "membership expires"
'Else
msg = "<b>wrong username or password</b>"
'End If
End if
rs.Close
Set rs = Nothing
End if
%>


This is the error I got:
Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

What's up?!

buntine
06-04-2004, 01:23 AM
That error is normally thrown when one of your strings is null. Make sure your Request.Form() variables contain values.

Also, you may want to look up the DateDiff() function for MS Access.

Regards.

weee
06-04-2004, 01:25 AM
I don't know what to do anymore... #$@#@@!

Where can I learn about the DateDiff()?

Thanks man!!!

buntine
06-04-2004, 02:13 AM
Look in MS Access' help files. Or do a google search...

lmf232s
06-04-2004, 09:30 AM
Do a
response.write SQL
response.end
right after the SQL statement.
and see what your SQL statement looks like.
You might see that something doesent look right.

simflex
06-04-2004, 10:08 AM
I see you have been struggling with this now for awhile.

Here is a deal for you.
Since I am not a php guy, I am just going to give you an access dateDiff function that works.
Run this code alone using your access query and once you are satisfied that with the result, then add the form object bit to it.

Select [id],[user],[pass],[serviceDate] FROM tstTBL Where (((DATEDIFF("d", [serviceDate], Date()))>=0));


Correction: My apology, I just saw php and assumed it was php.
It isn't.
In any case, your problem from looking at the code is with the datediff() function.
You can now integrate your asp bit with it.

lmf232s
06-04-2004, 01:26 PM
Have you tried to create a new variable = Date such as

Dim MyDate
MyDate = Date
This will set MyDate = to today's date. Then plug the variable into the SQL statement.

SQL = "SELECT id,user,pass,serviceDate " & _
"FROM tstTBL " & _
"WHERE (user = '" & Request.form("user") & "') and " & _
" (pass = '" & Request.form("pass") & "') and " & _
" (serviceDate > '" & MyDate & "')"

Not sure just a suggestion.
What is the format of servicedate is it date and time or just date?
Try this see if it works.

weee
06-04-2004, 01:57 PM
Here's the page...
what else can i do?

simflex
06-04-2004, 04:17 PM
I have downloaded a copy of your code and will fix it for you tonight.

Meanwhile, confirm that your boolean logic is correct.

You are saying essentially that username be match AND password must be match AND DATEDIFF(DAY, serviceDate, '" & Date() & "') must be equal to or greater than 0

So basically you are saying that ALL conditions in your where predicate must be true for any record to be retrieved, correct?

weee
06-04-2004, 08:34 PM
.

simflex
06-05-2004, 08:51 AM
sorry, Friday evenings are my hangout days with 3 and 4 yr old boys; so didn't get to look at your code last night.

In any case, I have resolved your little datediff issues but didn't test the rest of it, sorry.

Here is the major change I made:

(((DATEDIFF(d,[serviceDate],'" & Date() & "'))>=0));"
If you notice, this line of code is very similar to my original recommendation.

Second, I noticed there was problem terminating your strings.

and pass='" & Request.form("pass") <== no & "'
That will always present a problem.

The rest should be fairly easy for you, I hope.
If not, let us know.

lmf232s
06-05-2004, 03:15 PM
Weeeee take a look at your other post and see if it helps. I changed some of your code and and posted a working example.
http://www.webdeveloper.com/forum/showthread.php?s=&threadid=36525

simflex
06-05-2004, 04:30 PM
I forgot to mention one other very important point.
From looking at wee's code, and from looking at all the suggestions and sample codes, I didn't see anywhere where sreviceDate is being checked against 0.
In the where clause, wee has:

where (((DATEDIFF("d", [serviceDate], Date()))>=0));
but in his input form, there is only user name and password input forms.
So there really is no way to tell where (((DATEDIFF("d", [serviceDate], Date()))>=0)).
But the code I posted earlier is syntatically and logically correct.
If correct values for user, pass and servicedate are passed, the code will work well.

Until that happens, the code will NEVER work.
Sorry I didn't bring this up sooner.

weee
06-07-2004, 09:59 PM
Just wanted to say that I appriciate all of your help so much.
I figured it out and this is what I got now:


msg = ""

If request.form("password") <> "" Then
Dim MyDate
MyDate = Date

SQL = "Select id,user,pass,serviceDate FROM tstTBL Where user='" & Request.form("user") & "' and pass='" & Request.form("pass") & "'"

Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open SQL,DSN,3,1
If NOT rs.EOF Then
If rs("serviceDate") < Date then
msg = "membership expired"
Else
id = rs("id")
Session("login") = "True"
rs.Close
Set rs = Nothing
Response.redirect "sa.asp?id=" & id
End If
Else
msg = "<b>wrong pass or user</b>"
End if

rs.Close
Set rs = Nothing
End if


Again, Thanks a lot guys!!!

weee