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:
Business 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
Presentation Layer:Code:<WebMethod()> _ Public Function checkamount(ByVal name As String) As Integer Dim d As New dataweb.Service Return (d.checkamount(name)) End Function
If you know the problem with my codes, please reply me asapCode: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





Reply With Quote