Results 1 to 3 of 3

Thread: [2005] Error in my codes - 3 tier

  1. #1

    Thread Starter
    Addicted Member JuzMe's Avatar
    Join Date
    Jul 2006
    Posts
    209

    Smile [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
    I am such a VB.NET 2005 idiot. Sorry If I don't even know basic stuff.

  2. #2
    Hyperactive Member kayos's Avatar
    Join Date
    Apr 2004
    Location
    Largo, Florida
    Posts
    306

    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.


    If this post helps, please RATE MY POST!

    Using Visual Studio 2005 SE

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Error in my codes - 3 tier

    A data layer exposed as a web service? What's the point?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width