Microsoft VBScript 运行时错误 (0x800A0005)
无效的过程调用或参数: 'DATEADD'
无效的过程调用或参数: 'DATEADD'
Dim Db,Conn Db = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("01.mdb") Set Conn = Server.CreateObject("ADODB.Connection") Conn.open Db lid = 1 rid = 7 Lyear = "2012-6-5" '日期如果也加段的话自己搞吧,照葫芦画瓢 LHour = "5-16" '小时 时间段 按照时间规则 24以内 Lminute = "10-50" '分钟 时间段 60以内 'lid 开始id 'rid 结束id Call SetDate(lid,rid,Lyear,LHour,Lminute) '打开数据库自己加 Function SetDate(lid,rid,Lyear,LHour,Lminute) Dim Sql,Rs,Total,ydate,LHour_l,LHour_r Dim LHT_Hour,LHT_minute,Lht_Date Randomize LHour = Split(LHour, "-", -1, 1) LHT_Hour = LHour LHour_l = Int(LHour(1))-Int(LHour(0))+1 LHour_r = Int(LHour(0)) LHour = Int((LHour_l * Rnd)+LHour_r) Lminute = Split(Lminute, "-", -1, 1) LHT_minute = Lminute Lminute_l = Int(Lminute(1))-Int(Lminute(0))+1 Lminute_r = Int(Lminute(0)) Lminute = Int((Lminute_l * Rnd)+Lminute_r) Lsecond = Int((60 * Rnd) + 1) Lht_Date = FormatDateTime(Lyear&" "&LHour&":"&Lminute&":"&Lsecond) Response.write "时间段:"&FormatDateTime(Lyear&" "&LHT_Hour(0)&":"&LHT_minute(0)&":00")&"至"&FormatDateTime(Lyear&" "&LHT_Hour(1)&":"&LHT_minute(1)&":00")&"<br>" Set Rs = Server.Createobject("adodb.recordset") Total = 0 ydate = Lht_Date Sql = "select id,ydate from Table_1 where id >= "&lid&" and id <= "&rid 'Response.write sql Rs.Open Sql,Conn,1,1 If Rs.Bof Or Rs.Eof Then 'Response.write "False" Else Do Until Rs.EOF '当每超过三条数据的时候判断 If (Total Mod 3)=0 Then '随机根据当前时间生成时间,加(1-1000)秒随机数,可以换分钟,小时 ydate = DATEADD ("s" , Int((1000 * Rnd) + 1),ydate) '每3条+1天 If Total <> 0 Then ydate = DATEADD ("d" , 1, ydate) Total = 0 End If Else '随机根据当前时间生成时间 ydate = DATEADD ("s" ,Int((1000 * Rnd) + 1), ydate) End If Response.write "<br>ID:"&Rs("id")&" 更新时间:"&ydate&"<br>" Sql = "Update Table_1 Set ydate='"&ydate&"' Where id="&Rs("id") Response.write Sql Conn.Execute(Sql) Total=Total+1 Rs.MoveNext Loop End If Rs.Close Set Rs = Nothing 'Response.write "True" End Function '关闭数据库自己加 Conn.Close Set Conn = Nothing
Dim Db,Conn Db = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("01.mdb") Set Conn = Server.CreateObject("ADODB.Connection") Conn.open Db lid = 1 rid = 7 Lyear = "2012-6-5" '日期如果也加段的话自己搞吧,照葫芦画瓢 LHour = "7-9" '小时 时间段 按照时间规则 24以内 Lminute = "10-50" '分钟 时间段 60以内 'lid 开始id 'rid 结束id Call SetDate(lid,rid,Lyear,LHour,Lminute) '打开数据库自己加 Function GetDate(Lyeara,LHoura,Lminutea) Dim L_Hour,LHT_Hour,LHour_l,LHour_r,LHourb Dim L_minute,LHT_minute,Lminute_l,Lminute_r,Lminuteb,Lsecondb Randomize 'Response.write LHour_r L_Hour = Split(LHoura, "-", -1, 1) LHT_Hour = L_Hour LHour_l = Int(L_Hour(1))-Int(L_Hour(0))+1 LHour_r = Int(L_Hour(0)) LHourb = Int((LHour_l * Rnd)+LHour_r) L_minute = Split(Lminutea, "-", -1, 1) LHT_minute = L_minute Lminute_l = Int(L_minute(1))-Int(L_minute(0))+1 Lminute_r = Int(L_minute(0)) Lminuteb = Int((Lminute_l * Rnd)+Lminute_r) Lsecondb = Int((59 * Rnd) + 1) 'Response.write "<font color=red>"&Lyeara&" "&LHourb&":"&Lminuteb&":"&Lsecondb&"</font>" GetDate = FormatDateTime(Lyeara&" "&LHourb&":"&Lminuteb&":"&Lsecondb) Response.write "<br><font color=red>时间段:"&FormatDateTime(Lyear&" "&LHT_Hour(0)&":"&LHT_minute(0)&":00")&"至"&FormatDateTime(Lyear&" "&LHT_Hour(1)&":"&LHT_minute(1)&":00")&"</font>" End Function Function SetDate(lid,rid,Lyear,LHour,Lminute) Dim Sql,Rs,Total,ydate Randomize Set Rs = Server.Createobject("adodb.recordset") Total = 0 Sql = "select id,ydate from Table_1 where id >= "&lid&" and id <= "&rid 'Response.write sql Rs.Open Sql,Conn,1,1 If Rs.Bof Or Rs.Eof Then 'Response.write "False" Else Do Until Rs.EOF ydate = GetDate(Lyear,LHour,Lminute) '当每超过三条数据的时候判断 If (Total Mod 3)=0 Then '随机根据当前时间生成时间,加(1-1000)秒随机数,可以换分钟,小时 ydate = DATEADD ("s" , Int((1000 * Rnd) + 1),ydate) '每3条+1天 If Total <> 0 Then ydate = DATEADD ("d" , 1, ydate) Total = 0 End If Else '随机根据当前时间生成时间 ydate = DATEADD ("s" ,Int((1000 * Rnd) + 1), ydate) End If Response.write "<br>ID:"&Rs("id")&" 更新时间:"&ydate&"<br>" Sql = "Update Table_1 Set ydate='"&ydate&"' Where id="&Rs("id") Response.write Sql Conn.Execute(Sql) Total=Total+1 Rs.MoveNext Loop End If Rs.Close Set Rs = Nothing 'Response.write "True" End Function '关闭数据库自己加 Conn.Close Set Conn = Nothing