[2005] Error in my codes - 3 tier
I am doing fund transfer and to do that, I need to make sure the amount user entered is smaller than the amount of money he has in the database else it will return another label message. However, my codes do not work properly and only display the first message all the time.
Here are my codes:
Data Layer:
Code:
<WebMethod()> _
Public Function checkamount(ByVal name As String) As Integer
Dim strcon As String
Dim cn As New OleDb.OleDbConnection()
Dim i As Integer = 0
'Connection string
strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= C:\\temp\\zestbank.mdb;"
'Create a new connection based on the connection string
cn = New OleDb.OleDbConnection(strcon)
Dim cmd As New OleDbCommand
cmd.CommandText = "select count(*) from fund"
cmd.Connection = cn
cn.Open()
i = cmd.ExecuteScalar()
Dim pass(i - 1) As String
Dim reader As OleDbDataReader
cmd.CommandText = "select amount from fund where accountnumber = '" + name + "'"
reader = cmd.ExecuteReader
reader.Close()
cn.Close()
End Function
Business Layer:
Code:
<WebMethod()> _
Public Function checkamount(ByVal name As String) As Integer
Dim d As New dataweb.Service
Return (d.checkamount(name))
End Function
Presentation Layer:
Code:
Protected Sub bn_submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bn_submit.Click
If tb_amt.Text > a.checkamount(ddl_from.SelectedItem.Text) Then
Label7.Text = "Unable to transfer fund as there are not enough money in your account to transfer. Please re-enter a smaller amount to transfer." 'only display this message only
ElseIf tb_amt.Text < a.checkamount(ddl_from.SelectedItem.Text) Then
Label7.Text = "Success!"
End If
End Sub
If you know the problem with my codes, please reply me asap
Re: [2005] Error in my codes - 3 tier
it may just be me, but the data layer function "checkamount" doesn't have a "Return" statement in it anywhere... so it is a function that will always get "Nothing" back. the first step would be to return some data there.
Re: [2005] Error in my codes - 3 tier
A data layer exposed as a web service? What's the point? :D