Sql 正确,人们需要自行决定使用这些答案。我只是想帮你指出正确的方向。请随意添加您认为更合适的答案。这比说出当前答案的错误更有帮助。:)对于OP和像我这样的人来说,看看应该如何回答问题是一个很好的建议。已经有很多在ADODB中使用参数化查询的例子了。@Lanky

Sql 正确,人们需要自行决定使用这些答案。我只是想帮你指出正确的方向。请随意添加您认为更合适的答案。这比说出当前答案的错误更有帮助。:)对于OP和像我这样的人来说,看看应该如何回答问题是一个很好的建议。已经有很多在ADODB中使用参数化查询的例子了。@Lanky,sql,vbscript,asp-classic,Sql,Vbscript,Asp Classic,正确,人们需要自行决定使用这些答案。我只是想帮你指出正确的方向。请随意添加您认为更合适的答案。这比说出当前答案的错误更有帮助。:)对于OP和像我这样的人来说,看看应该如何回答问题是一个很好的建议。已经有很多在ADODB中使用参数化查询的例子了。@Lankymart这看起来更好吗?如果你发现有什么问题,请告诉我。我添加了一个用于参数化查询的函数,以使其更易于使用。您知道,您不必创建ADODB.Connection如果您传递activeconnection一个有效的连接字符串,它将为您实例化和打开连


正确,人们需要自行决定使用这些答案。我只是想帮你指出正确的方向。请随意添加您认为更合适的答案。这比说出当前答案的错误更有帮助。:)对于OP和像我这样的人来说,看看应该如何回答问题是一个很好的建议。已经有很多在ADODB中使用参数化查询的例子了。@Lankymart这看起来更好吗?如果你发现有什么问题,请告诉我。我添加了一个用于参数化查询的函数,以使其更易于使用。您知道,您不必创建
ADODB.Connection
如果您传递
activeconnection
一个有效的连接字符串,它将为您实例化和打开连接,并在命令发布时处理它。因此,
.ActiveConnection=CONNECTION\u INFO
也会起作用。不应鼓励推荐一种不涉及保护的方法,如使用参数化查询等。这两个答案在这方面都有不足。@lankymart你绝对正确,人们需要自行决定使用这些答案。我只是想帮你指出正确的方向。请随意添加您认为更合适的答案。这比说出当前答案的错误更有帮助。:)对于OP和像我这样的人来说,看看应该如何回答问题是一个很好的建议。已经有很多在ADODB中使用参数化查询的例子了。@Lankymart这看起来更好吗?如果你发现有什么问题,请告诉我。我添加了一个用于参数化查询的函数,以使其更易于使用。您知道,您不必创建
ADODB.Connection
如果您传递
activeconnection
一个有效的连接字符串,它将为您实例化和打开连接,并在命令发布时处理它。所以
.ActiveConnection=CONNECTION\u INFO
也可以工作。
'CREATION OF COUNTER FOR MONTHS OF 30 DAYS
    '------------------------------------------------------------------------------------
Set rs_Results = Server.CreateObject("ADODB.Recordset") -(creation of recordset for opening sql query)

    If month_num = 4 Or month_num = 6 month_num = 9 Or month_num = 11 Then -(checks the specific months with 30 days)

    For day_counter=1 To 30 -(creates a counter for days from 1 to 30 since is the case for months 

of 30 days only)

        search_date = cDate(day_counter &"-"& month_num &"-"& year_num) -(inserts the day counter along with the
 month and year counter separating them by "-" making it a valid date after the conversion)

        converted_date= Clng(search_date) -(converts the date of the variable 'search_date' to numbers)
    strSQL_CIP_Date="SELECT * FROM data_storage WHERE creation_date=" & converted_date 

    'cn_body.execute (strSQL_CIP_Date) -(when using this method on the portion of page that shows the results it throws 
an error which is: 'ADODB.Recordset error '800a0e78' Operation not allowed if the object is closed.', in this case the 
query is executed the times it should, but the results aren't shown because of the mentioned error)

        rs_Results.open strSQL_CIP_Date,cn_body,1,1 

(cn_body is the string connection which is stored into another page, 
    what i'm doing here is opening the sql query using the recordset which is the method i used for other queries without bigger issues,
    but for some reason here it is not working, only runs 2 times then it appears this error: 
    'ADODB.Recordset error '800a0e79'

'Operation not allowed if the object is open')

        response.write day_counter & " " & strSQL_CIP_Date & "<br><br><br><br>" 
-(prints the query with the converted date to ask to the database)
    Next
End If
strSQL_CIP_Date = "SELECT * FROM data_storage WHERE creation_date BETWEEN '" & strStartDate & "' AND '" & strEndDate & "'"
strSQL_CIP_Date = "SELECT * FROM data_storage WHERE creation_date BETWEEN #" & strStartDate & "# AND #" & strEndDate & "#"
strSQL_CIP_Date = "SELECT * FROM data_storage WHERE MONTH(creation_date) = 11"
Set Cn = Server.CreateObject("ADODB.Connection")
Cn.Open CONNECTION_INFO

function dbPara(sql, params)
    dim cmd
    set cmd = Server.CreateObject("ADODB.Command")
    with cmd
        .CommandText = sql
        set .ActiveConnection = cn
    end with

    if NOT isEmpty(params) then
        set rs = cmd.execute(, params)
    else
        set rs = cmd.execute()
    end if

    set dbPara = rs
end function

strSQL_CIP_Date = "SELECT * FROM data_storage WHERE creation_date BETWEEN ? AND ?"
set strRS = dbpara(strSQL_CIP_Date,array(converted_date, converted_date+29))
do until strRS.eof
   'insert code for each entry here
   strRS.movenext
loop