幫忙改個小錯誤.....改完馬上結帖...............
<%
set conn=server.CreateObject( "ADODB.Connection ")
dsn= "provider=sqloledb.1;date source=172.24.17.103;initial catalog=web-ceshi;user id=sa;password=123456 "
conn.Open dsn
sql= "update [Mat_Sal_D] set Sal_Price= ' "&Pr& " ',Sal_Qty= ' "&Qt& " ' where Sal_D_ID like ' "&ID1& " ' "
conn.Execute(sql) (line 20)
conn.Close
set conn=nothing
%>
錯誤提示:
Microsoft OLE DB Provider for SQL Server (0x80040E07)
轉換資料型別從 varchar 到 numeric 時發生錯誤。
/Mat/web.Update2XS.asp, line 20
------解决方案--------------------代码没什么问题,就是最上面应该加上判断语句,不然出错也没有提示。
--------------------------------
<%
dim ID,Nm,ID1,Br,St
ID1=Trim(Request.Form( "txtID1 "))
ID=Trim(Request.Form( "txtID "))
Nm=Trim(Request.Form( "txtNm "))
Pr=Trim(Request.Form( "txtPr "))
Qt=Trim(Request.Form( "txtQt "))
%>
--------------------------------
这里改为:
---------------------------------
<%
dim ID,Nm,ID1,Br,St
if ID1 <> " " and ID <> " " and Nm <> " " and Pr <> " " and Qt <> " " then
ID1=Trim(Request.Form( "txtID1 "))
ID=Trim(Request.Form( "txtID "))
Nm=Trim(Request.Form( "txtNm "))
Pr=Trim(Request.Form( "txtPr "))
Qt=Trim(Request.Form( "txtQt "))
else
response.write " <script> alert( '信息不全或有误,请重新填写! ');history.back(-1); </script> "
response.end
end if
%>
-----------------------------------------
上面的判断条件自己看着改,看你需要什么样的条件。如果你前面页面传过来的数据为空
或者不符,当然会出错。要加一些判断语句,这样出错也能立即发现。