Send a suggestion!

We're building a brand new version of the site, and we'd love to hear your ideas

Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Banking Database

Last post 03-18-2008 8:12 PM by rivierasoftware. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 03-15-2008 9:05 PM

    • dasad
    • Not Ranked
    • Joined on 03-15-2008
    • Ireland
    • New Member
    • Points 15

    Banking Database

    I have an access database with customer bank records and have created an ATM program using .NET. The user enters their UNIQUE PIN to access their personal account but i am having trouble to show their balance by using their UNIQUE PIN to get their balance. Here is what i have tried.

    [CODE=VB.NET]

    Public Class frmBalance

    Dim objDS As New DataSet

    Dim objConn As New OleDb.OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0;Data Source=bank.mdb")

    Dim objSqlStr As String = "SELECT * FROM CustomerAccounts"

    Dim objDA As New OleDb.OleDbDataAdapter(objSqlStr, objConn)Private Sub frmBalance_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    objDS.Clear()

    objDA.FillSchema(objDS, SchemaType.Source, "CustomerAccounts")

    objDA.Fill(objDS, "CustomerAccounts")

    Dim objRow As DataRow

    objRow = objDS.Tables("CustomerAccounts").Rows.Find(frmATM.txtDisplay.Text.ToString)

    txtBalance.Text = objRow.Item("Balance")

    End Sub

    End Class

     

    [/CODE]

    • Post Points: 15
  • Advertisement

    • Red Gate Software

    Advertisement

    Want to boost your .NET application performance?

    Some developers always seem to write efficient and lightening-fast code. What is their secret? It’s ANTS Profiler. “We improved the performance of the application up to 10 times” Dan Ports, Intrigma.

    Try it for yourself now.

  • 03-18-2008 3:29 AM In reply to

    • CFQüeb
    • Top 500 Contributor
    • Joined on 04-27-2007
    • Mexico
    • Member
    • Points 275

    Re: Banking Database

    Why not use a filtered query?

    Dim objSqlStr As String = "SELECT * FROM CustomerAccount WHERE CustomerId =" + YourTextBox.Text + "'"

    You are using the Find statement...of course that the error is not the use of a key?

    Attempt to Use the Load statement or ImportRow() statement to filter the record and copy only this line into a cloned datatable?. On this way.. only the record that you need wil be available.

    To share info in crossed forms, please review the following therad (in C#, but.. very similar in VB.NET):

    http://www.developerfusion.co.uk/forums/t/52181/

    On this way.. you only will be pass the customer id to the frmBalance constructor.

    Regards

    • Post Points: 5
  • 03-18-2008 8:12 PM In reply to

    Re: Banking Database

    Ok, first off, you're telling the program to retrieve all account details from the CustomerAccounts table. This is usually a bad idea as it causes unnecessary load time. In the case of a banking application, this is a lot more bad as you're retrieving all the account details (including the unique PIN) of every customer.

    I would recommend storing PIN numbers encoded as an MD5 hash, then comparing a hash of the user's input to that, so the real pin is never communicated, and doesn't physically exist anywhere in it's PIN format.

    Secondly, to cut down on the traffic, use a WHERE clause in your T-SQL to get the data:
    SELECT * FROM CustomerAccounts WHERE (lngAccountNumber = 03747263 AND strPIN = '<md5 hash of user's pin as entered>')
    Alternately, you could use a stored procedure, as previously suggested, to further improve speed and pass the account number and pin hash to the stored procedure as parameters.

    As for why your current query is not working:
    "txtDisplay.Text.ToString?" (assuming txtDisplay is a TextBox) The 'Text' property will return a string containing the contents of the textbox. ToString is not needed here and only increases processing time (every little helps ;) )
    Also, is txtDisplay a public member of frmATM? By default, a control is a Protected object. Perhaps accessing the form's Controls collection would be better, or creating a public property on frmATM to pass the value of the textbox to foriegn forms.

    Lastly, exceptions are your friend. Put your code in a Try Catch block and analyse any errors thrown using message boxes or logging. This should give you some info on where you're going wrong.

    Let me know if this is any help to you.

    Robert Hardy
    Lead Developer
    Riviera Software
    http://www.rivierasoftware.co.uk
    • Post Points: 5
Page 1 of 1 (3 items)