【发布时间】:2019-11-29 15:09:52
【问题描述】:
我被困在如何完成标题中提到的任务,你看,几天,也许几周我问如何创建某种搜索方法来包括整个月,这与此有关我又被困的任务-.-'
我遇到了搜索方法,但我不知道如何要求数据库带来与搜索匹配的所有行,例如,假设我输入了对当年 11 月当月的搜索2019 年,我插入了 5 行,我需要搜索返回当年这个月插入的这 5 行。
这是我目前正在尝试的,但没有结果
下面提到的变量:'num_month'和'num_year'是通过搜索组合框插入到另一个页面中,'cn_body'这个东西是存储在别处的连接字符串页面
'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
我也尝试了循环方法,do,do while,for,if,do while not,loop until,while循环等等,并且得到了相同的结果。
所以你有它,我不知道我在代码中提到的任何错误的原因,任何形式的帮助都会很棒,请问你觉得需要什么,提前谢谢
【问题讨论】:
-
等等……你现在在做什么?!?
-
嗨@Lankymart 目前我正在尝试在 For 循环中执行查询,我需要的是在每个月的每一天执行查询并检索数据库中存在的查询
-
我知道你在做什么,我只是震惊了。
-
为什么?是不是太乱了?
标签: sql vbscript asp-classic