参数类型错误,超出可接受的范围,或者彼此冲突VBSCRIPT ERROR

时间:2015-12-07 18:55:02

标签: vbscript asp-classic adodb

代码:

 <%@LANGUAGE="VBSCRIPT"%>

<% 
set updatetime = Server.CreateObject("ADODB.Connection")
updatetime.open "DRIVER=SQL Server;***************************************"
If request.form("in_out")="checkin" then
updatetime.execute ("insert into hourlist (username, checkintime, paid,breakCount) values ('"&session("MM_username")&"', '"&Now()&"', 0, 2) ")

End if

If request.form("in_out")="checkout" then
updatetime.execute ("update hourlist set checkouttime='"&Now()&"' where username='"&session("MM_username")&"' and checkouttime is NULL")
End if
If request.form("in_out")="breakcheckin" then
updatetime.execute ("update  hourlist set  breakCheckIn='"&Now()&"' where ID='"&session("MM_ID")&"'  ")
updatetime.execute ("update  hourlist set  breakCheckOut=Null where ID='"&session("MM_ID")&"' and breakCheckOut is not NULL  ") 
End if
If request.form("in_out")="breakcheckout" then
updatetime.execute ("select  breakCheckIn from hourlist where ID='"&session("MM_ID")&"'  ")
Dim BTD
BTD=Round(Csng(DateDiff("n", (updatetime.Fields.Item("breakCheckIn").Value), (Now()))), 2)
updatetime.execute ("update hourlist set breakCheckOut='"&Now()&"', breakCount=breakCount-1 where ID='"&session("MM_ID")&"' ")
updatetime.execute ("update hourlist set breakTime='"&BTD&"' where ID='"&session("MM_ID")&"' ")
updatetime.execute ("update hourlist set breakCheckIn=NULL where ID='"&session("MM_ID")&"' and breakCheckIn is not NULL ")
End if
updatetime.close
set updatetime=nothing
response.redirect "employee.asp?in_out="&request.form("in_out")

%>

根据收音机选择我做不同的事情,我得到&#34; ADODB.Connection错误&#39; 800a0bb9&#39; &#34; 21行的错误(BTD = Round ... line)有人能告诉我在那条线路上我做错了什么吗?我写过&#34; updatetime.Fileds&#34;错了还是什么?

我的坏英语。

2 个答案:

答案 0 :(得分:0)

您的updatetime是连接,而不是记录集(带.Fields)。您可能需要存储

中的结果/记录集

updatetime.execute ("select breakCheckIn from hourlist where ID='"&session("MM_ID")&"' ")

在变量中并在后面的语句中使用它的字段(或者 - 更好 - 参数化查询)。

更新评论:

使用Set将对象(记录集)分配给变量。

答案 1 :(得分:0)

Dim myConnection, myRecordset    
set myRecordset = Server.CreateObject("ADODB.Recordset")
set myConnection = Server.CreateObject("ADODB.Connection")
myConnection.Open "DRIVER=SQL Server;***************************************"

myRecordset.Open "select breakCheckIn from hourlist where ID='"&session("MM_ID")&"' ", myConnection

Dim bciValue = myRecordset("breakCheckIn")
Response.Write "BreakCheckIn value is: " & bciValue

myRecordset.Close
myConnection.Close