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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Should I use parameters?

Status
Not open for further replies.

mmaz

Programmer
Nov 22, 2000
347
Hello! I'm calling a CR8 report from an ASP, using an ODBC connection to SQL Server. When I call my report, it's getting all the records from the database, regardless of what I wrote in my SQL statement. I assumed that I would not need parameters with this SQL statement. Am I wrong? I want to get the records whose create_date is between 10/30/2000 and 11/02/2000. Here's my code:

Set oConn = Server.CreateObject("ADODB.Connection")


oConn.Open "DSN name","username","pwd"
set session("oRs") = server.CreateObject("ADODB.recordset")

strSQL = "SELECT * FROM tableName WHERE(Create_Date BETWEEN CONVERT(DATETIME, '2000-10-30 00:00:00', 102) AND CONVERT(DATETIME, '2000-11-02 00:00:00', 102))"

-- this should only get the records from 10/30/2000 to 11/02/2000 but the report is displaying everything in the db


session("oRs").Open strSQL,oConn

set Database = session("oRpt").database
set Tables = Database.Tables
set Table1 = Tables.Item(1)
Table1.SetLogonInfo "DSN name","tableName","username","password"

session("oRpt").DiscardSavedData

Table1.SetPrivateData 3, session("oRs")

Thanks for your help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top