ASP.NET System.FormatException

时间:2011-03-17 16:51:02

标签: asp.net web-services exception

我有以下错误:

   Stack Trace:   
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)     
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)     
at DocumentManager.Web.MidasInterface.MIDASCustomerInfo.GetBaseRate(String ccy, String brcod) in D:\2010\RETAIL\DocumentManager.Web\Web References\MidasInterface\Reference.vb:line 696   
...

内心的信息:

System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.    
at iMIDAS.MIDASCustomerInfo.GetBaseRate(String ccy, String brcod)    

db

中的Web方法查询
<WebMethod()> Public Function GetBaseRate(ByVal ccy As String, ByVal brcod As String) As ResponseObject
        Dim connAS400 As New Data.OleDb.OleDbConnection
        Dim dsAS400 As Data.DataSet
        Dim cmdAS400 As Data.OleDb.OleDbCommand
        Dim retVal As Object
        Try
            connAS400.ConnectionString = CreateConnectionStringMidas(DataSource, DataCatalog, DataUser, DataPassword)
            cmdAS400 = New Data.OleDb.OleDbCommand(CreateSQLBaseRate(ccy, brcod), connAS400)
            connAS400.Open()
            retVal = cmdAS400.ExecuteScalar()
            If IsNothing(retVal) Or IsDBNull(retVal) Then
                oResponse.ResponseState = False
                oResponse.ResponseMessage = String.Format("No Records Found for base rate code [{1}]!", brcod)
            Else
                oResponse.ResponseState = True
                oResponse.ResponseData = CType(retVal, String).ToString().ToUpper()
            End If
            Return oResponse
        Catch ex As Exception
            Throw ex
        Finally
            connAS400.Close()
        End Try
    End Function

有什么想法吗?

1 个答案:

答案 0 :(得分:3)

我很确定这就是这条线:

oResponse.ResponseMessage = String.Format("No Records Found for base rate code [{1}]!", brcod)

应该是零索引,而不是一个索引,所以:

oResponse.ResponseMessage = String.Format("No Records Found for base rate code [{0}]!", brcod)