大家好:
正常是可以瀏覽,但如果網頁一直重新整理的話,webservice好像就會出錯(如下)..有時候是陣列索引超出範圍但我索引值都取範圍內,或者直接顯示無法指出的錯誤,接著其他WebMethod都不能用
想問有解決的方法嗎? 謝謝
asp
dim SoapClient
set SoapClient = CreateObject("MSSOAP.soapClient30")
SoapClient.ClientProperty("ServerHTTPRequest") = True
SoapClient.mssoapinit "http://copp.com.tw/webservice/webservice/WebService1.asmx?WSDL"
stdata=SoapClient.userdata(udno,uname)
if stdata = "False" then
response.write "錯誤"
else
stArray=Split(stdata,",")
<%=stArray(0)%>
<%=stArray(1)%>
<%=stArray(2)%>
.
.
.
<%=stArray(6)%>
endif
web service
<WebMethod(Description:="資料")>
Public Function userdata(uid As String, uname As String) As String
Dim connetionString As String
Dim conn As OleDbConnection
Dim cmd As OleDbCommand
Dim reader As OleDbDataReader
Dim sql As String
Dim popdata(6) As String
Dim LastStr As String
connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../../st/db/db.mdb")
conn = New OleDbConnection(connetionString) '連接資料庫
Try
conn.Open()
sql = "Select * From studdata where 編號 = """ & Trim(uid) & """and 姓名=""" & Trim(uname) & """"
cmd = New OleDbCommand(sql, conn)
reader = cmd.ExecuteReader()
If reader.HasRows Then
While reader.Read()
popdata(0) = reader("姓名")
popdata(1) = reader("E_mail")
popdata(2) = reader("密碼")
popdata(3) = reader("組別")
popdata(4) = reader("地址")
popdata(5) = reader("編號")
popdata(6) = reader("電話")
LastStr = Join(popdata, ",")
Return LastStr
End While
Else
Return False
End If
conn.Close()
Catch ex As Exception
Return False
End Try
End Function
我把vb.net的陣列拿掉,asp只顯示soap導出的值,一直按重新整理 還是會"出現無法指出的錯誤",oledb的問題,在想是不是access資料庫連線問題..好像是資料庫lock住..
Try
conn.Open()
sql = "Select * From studdata where 編號 = """ & Trim(uid) & """and 姓名=""" & Trim(uname) & """"
cmd = New OleDbCommand(sql, conn)
reader = cmd.ExecuteReader()
If reader.HasRows Then
Return True
Else
Return False
End If
popdata = Nothing
reader.Close()
conn.Close()
conn = Nothing
Catch ex As Exception
Throw
End Try
asp
dim SoapClient
set SoapClient = CreateObject("MSSOAP.soapClient30")
SoapClient.ClientProperty("ServerHTTPRequest") = True
SoapClient.mssoapinit "http://copp.com.tw/webservice/webservice/WebService1.asmx?WSDL"
stdata=SoapClient.userdata(udno,uname)
response.write stdata