當前問題:當在本地運行asmx文件以檢查它是否正常工作時,不斷出現的錯誤是沒有給出值,如下所示。現在我已經添加了參數,但錯誤仍然出現。OleDbException:沒有給出一個或多個必需參數的值
但是現在,我覺得錯誤不在asmx中,因爲人們已經改變了SQL以正確運行。這是傳遞所需信息的aspx文件。傳遞已設置的會話變量是否存在問題?
Dim Secure As New Visa.VISAServices()
Dim authHeader As New Visa.AuthenticationHeader()
authHeader.username = "HSBC"
authHeader.password = "password"
Secure.AuthenticationHeaderValue = authHeader
Session("sessionsortnum") = sortnum.Text
Session("sessionaccount") = account.Text
'Change type for the sortcode
Dim sortcode As String = CType(Session.Item("sessionsortnum"), String)
Dim accountnumber As String = CType(Session.Item("sessionaccount"), String)
lblVisa.Text = Secure.AuthenticateCardSecure(pin.Text, sortnum.Text, account.Text)
'NEEDS TO STAY HERE DO NOT MOVE!
Session("sessioncase") = lblVisa.Text
Dim selectcase As String = CType(Session.Item("sessioncase"), String)
'Tests - Being sent to the session var
testsort.Text = sortcode
testbank.Text = accountnumber
testselectc.Text = selectcase
這是怎樣的會議正在從被連接到與SORTCODE,ACCOUNTNUMBER和selectcase都正確顯示一個服務傳遞。
這是調用ASMX文件:
Private Sub checkbalance(ByVal sender As Object, ByVal e As System.EventArgs)
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
Select Case testselectc.Text
Case "1111111111"
'Dim lloydsbalance As New Lloyds.
'screen.Text = lloydsbalance.overdraft(accountnumber)
Case "2222222222"
Dim barclaysbalance As New Barclays.Transactions()
screen.Text = barclaysbalance.overdraft(accountnumber, sortcode)
Case "3333333333"
Dim santanderbalance As New Santander.Santander()
screen.Text = santanderbalance.overdraft(accountnumber, sortcode)
Case "4444444444"
Dim HSBCbalance As New HSBC.HSBC()
screen.Text = HSBCbalance.OverDraft(accountnumber)
Case "5555555555"
Dim halifaxbalance As New Halifax.Halifax()
screen.Text = halifaxbalance.overdraft(accountnumber)
Case "6666666666"
Dim natwestbalance As New Natwest.natwest()
screen.Text = natwestbalance.overdraft(accountnumber, sortcode)
End Select
End Sub
原來的問題:每當我在本地運行ASMX只是爲了檢查如果是工作,我只是得到一個錯誤。我檢查了我正在調用的函數,但是我找不到該錯誤。我希望有人能夠發現我做錯了什麼。
錯誤:
System.Data.OleDb.OleDbException: No value given for one or more required parameters. at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) at HSBC.over(Int64 accountnumber) at HSBC.OverDraft(Int64 accountnumber)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Overdraft Call
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<WebMethod()> Public Function OverDraft(ByVal accountnumber As Long) As String
Return over(accountnumber)
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Overdraft function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Creates a service web method
Private Function over(ByVal accountnumber As Long) As String
'Open the connection to the database
Dim BalanceDr As OleDbDataReader
Dim connectioncmd As OleDbCommand
Dim connection As OleDbConnection
Dim connx As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../database/HSBc.mdb") & ";"
Dim SQL As String = "SELECT Customer_Overdraft FROM Customer WHERE Account_Number=?"
Dim overdraft As String
connection = New OleDbConnection(connx)
connectioncmd = New OleDbCommand(SQL, connection)
connection.Open()
'Create a DataReader that will return information.
BalanceDr = _
connectioncmd.ExecuteReader(CommandBehavior.CloseConnection)
If BalanceDr.Read() Then
'A row was returned
overdraft = BalanceDr(0)
Else
'A row was not returned
overdraft = "No Balance For Account Found"
End If
BalanceDr.Close()
Return overdraft
End Function
ACCOUNTNUMBER被存儲在被帶回由其他人創建的服務的會話,我知道這是得到正確傳遞如初頁面上我檢查,這是正確的一個被髮送和使用。
任何人有任何建議嗎?我還將所有必需的權限添加到數據庫中。
請問現在如何把該帳戶數?對不起,我對這件事情有點遺憾。我知道我閱讀過使用使用陳述,但是我又一次失去了一點。同樣在VB Web開發人員中,我得到的是oledbparameter是一種類型,不能用作表達式。此外,我收到一個錯誤,錯誤=無法在OleDbParameter行中定義。這是一個asmx頁面 – user1134409 2012-01-11 22:35:28
它是以Dim accountParam作爲OleDbParameter行開始的部分。我們聲明一個參數,將其添加到屬於該命令的參數集合中,然後將該參數的值設置爲帳號。當OleDb驅動程序處理此查詢時,它將用accountParam值替換問號。如果有多個參數,則按它們在查詢中出現的順序添加它們。 – dash 2012-01-11 22:39:25
就像我上面提到的,我在VB中出現錯誤oledbparameter是一種類型,不能用作表達式。此外,我收到一個錯誤,錯誤=無法在OleDbParameter行中定義。 – user1134409 2012-01-11 22:45:49