Web服务超时,错误说明问题在于调用lblBalance.text

时间:2012-01-06 13:51:02

标签: asp.net web-services

我正在为uni工作创建一个银行系统,但是我遇到一个问题,即在调用aspx文件时需要一段时间才能加载,这最终会导致它超时。

这就是我在asmx文件中的内容

Private Function CheckBal(ByVal accountnumber As Long) As String

        'Database drivers, connections and commands
        Dim BalanceDr As OleDbDataReader
        Dim BalanceConn As OleDbConnection
        Dim BalanceCmd As OleDbCommand

        'Database connection string
        Dim Connx As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../database/HSBC.mdb") & ";"

        'SQL

        Dim SQL As String = "SELECT Transaction_Amount FROM Transaction WHERE Account_Number =" & accountnumber & ";"

        Dim bal As String

        'Open the connection to the database
        BalanceConn = New OleDbConnection(Connx)
        BalanceCmd = New OleDbCommand(SQL, BalanceConn)
        BalanceConn.Open()

        'Create a DataReader that will return information.
        BalanceDr = _
        BalanceCmd.ExecuteReader(CommandBehavior.CloseConnection)

        If BalanceDr.Read() Then
            'A row was returned
            bal = BalanceDr(0)
        Else
            'A row was not returned
            bal = "No Name Found"
        End If

        BalanceDr.Close()
        Return bal
    End Function
End Class

这是调用此函数的aspx文件中的函数

Dim balance As New test.HSBC()
        Dim sortcode As String = CType(Session.Item("sessionsortnum"), String)
        Dim accountnumber As String = CType(Session.Item("sessionaccount"), String)
        Dim selectcase As String = CType(Session.Item("sessioncase"), String)
        testsort.Text = sortcode
        testbank.Text = accountnumber
        testselectc.Text = selectcase

        Response.Write(sortcode & " " & accountnumber & " " & selectcase)

        lblBalance.Text = balance.CheckBalance(accountnumber)

有没有人建议什么可以导致它超时?

0 个答案:

没有答案