Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

No value given for required parameters????

Status
Not open for further replies.

crashc123

Technical User
Oct 3, 2001
80
0
0
US
Dim cnnSearch ' ADO connection
Dim rstSearch ' ADO recordset

Dim strSQL ' The SQL Query we build


Dim t ' Today's Date
Dim vbShortDate ' So the Date can be mm/dd/yy
vbShortDate = 2
Dim w ' Week from today's date

t = FormatDateTime(Now(),vbShortDate) 'Today's date
w = DateAdd("d","7",Now()) 'week from today's date
w = FormatDateTime(w,vbShortDate)
Set cnnSearch = Server.CreateObject("ADODB.Connection")


cnnSearch.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\
' Now we do our statement to query db.
'find records where due date is between today and a week from today
strSQL = "Select * FROM Projects " _
& &quot;WHERE DueDate >= &quot;& t &&quot; And DueDate <= &quot;& w &&quot; &quot; _
& &quot;ORDER by DueDate&quot;

set rstSearch = cnnSearch.Execute(strSQL)



Last line is the one that is getting the error message.
Have also tried to use
Set rstSearch = Server.CreateObject(&quot;ADODB.Recordset&quot;)
before SQL statement but get same error

Can anyone see what is wrong?
Thanks
 
Try putting pound sign delimiters around the date strings -
Code:
&quot;WHERE DueDate >= #&quot;& t &&quot;# And DueDate <= #&quot;& w &&quot;# ORDER BY etc.&quot;
 
Tried using the #'s and am still getting the same error:

strSQL = &quot;Select * FROM Projects &quot; _
& &quot;WHERE DueDate >= #&quot;& t &&quot;# And DueDate <= #&quot;& w &&quot;# &quot; _
& &quot;ORDER by DueDate&quot;

set rstSearch = cnnSearch.Execute(strSQL)'<------This is the line that gets the error

Any other ideas?
Thanks
 
Change ur SQL like this and try
strSQL = &quot;Select * FROM Projects &quot; _
& &quot;WHERE DueDate >= '&quot;& t &&quot;' And DueDate <= '&quot;& w &&quot;' &quot; _
& &quot;ORDER by DueDate&quot;

set rstSearch = cnnSearch.Execute(strSQL)


Sunil
 
That one doesn't work either. Still get the same message
Grrr! What is going on? Does anyone have any Ideas?

Using IIS 5.0 and Access 2000. Here's my complete page.

<% @ Language=VBScript %>
<% Option Explicit %>
<% Response.Buffer = True %>

<html>
<Head>
<Title>Projects Due This Week</Title>
</Head>
<Body>

<--! #include file=&quot;ADOvbs.inc&quot; -->
<H2>These Projects are due this week:</h2>
<%
'' Declare our variables
Dim cnnSearch ' ADO connection
Dim rstSearch ' ADO recordset

Dim strSQL ' The SQL Query we build


Dim t ' Today's Date
Dim vbShortDate ' So the Date can be mm/dd/yy
vbShortDate = 2
Dim w ' Week from today's date

t = FormatDateTime(Now(),vbShortDate) 'Today's date
w = DateAdd(&quot;d&quot;,&quot;7&quot;,Now()) 'Week from today's date
w = FormatDateTime(w,vbShortDate)
Set cnnSearch = Server.CreateObject(&quot;ADODB.Connection&quot;)


cnnSearch.Open &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\
' Now we do our statement to query db.
'find records where due date is between today and a week from today
strSQL = &quot;Select * FROM Projects &quot; _
& &quot;WHERE DueDate >= '&quot;& t &&quot;' And DueDate <= '&quot;& w &&quot;' &quot; _
& &quot;ORDER by DueDate&quot;

set rstSearch = cnnSearch.Execute(strSQL)

'Here is were I build the table to view it

' Close our recordset and connection and dispose of the objects
rstSearch.Close
Set rstSearch = Nothing
cnnSearch.Close
Set cnnSearch = Nothing


%>
</Body>
 
If you response.write the strSQL and run that as a query in access, does it work??
 
Tack this onto the end of your connection string and see if that helps:

;Persist Security Info=False

so that it would now look like this:

&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\ Security Info=False&quot;

I don't think the problem is your SQL Statement, but like harmmeijer said, I would try to response.write() the statement and look to see what you have if my solution doesn't fix the problem. Take it over to Access and try to execute it in the Query Builder...
penny.gif
penny.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top