473,405 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Database help

Hi,
I have an access database of bank customers which include a unique pin number for each customer.
I have an atm part to my program and want the pin enrty form to read the unique pins from the database to allow access or not. What i have so far below only reads the first pin from my database! Any ideas?

Expand|Select|Wrap|Line Numbers
  1.  
  2.     Private Sub btnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnter.Click
  3.  
  4.         Dim balance As New frmBalance
  5.  
  6.         If txtDisplay.Text = CStr(objDS.Tables(0).Rows(rowIndex)("PIN")) Then
  7.             Me.Hide()
  8.             balance.Show()
  9.         End If
  10.  
  11.     End Sub
  12.  
  13.  
Mar 13 '08 #1
12 986
nateraaaa
663 Expert 512MB
What is the value of rowIndex? If you want to search the entire table you will need to use a loop.
Expand|Select|Wrap|Line Numbers
  1.  for(int i = 0; i < objDS.Tables.Rows.Count; i++) 
  2. {
  3. If txtDisplay.Text = CStr(objDS.Tables(0).Rows(i)("PIN")) Then
  4. Me.Hide()
  5. balance.Show()
  6. End If
  7. }
  8.  
Nathan
Mar 13 '08 #2
kunal pawar
297 100+
U can used rowfilter property of defaultview class of dataset.table(). this will help to filter record in ur datatable
Mar 14 '08 #3
debasisdas
8,127 Expert 4TB
How you will find the unique PIN ?

Are you passing anything to the database like the user name or Account number or anything else ?
Mar 14 '08 #4
What is the value of rowIndex? If you want to search the entire table you will need to use a loop.
Expand|Select|Wrap|Line Numbers
  1.  for(int i = 0; i < objDS.Tables.Rows.Count; i++) 
  2. {
  3. If txtDisplay.Text = CStr(objDS.Tables(0).Rows(i)("PIN")) Then
  4. Me.Hide()
  5. balance.Show()
  6. End If
  7. }
  8.  
Nathan
i did that and it shows up errors when 'int=0' is declared, for the '{' , and for (i) after rows!!
Mar 14 '08 #5
How you will find the unique PIN ?

Are you passing anything to the database like the user name or Account number or anything else ?
each customer is given a unique pin that no one else can get so if they enter that number they can withdraw money. so no just the pin.
Mar 14 '08 #6
U can used rowfilter property of defaultview class of dataset.table(). this will help to filter record in ur datatable
thank you.how would i use this?
Mar 14 '08 #7
nateraaaa
663 Expert 512MB
i did that and it shows up errors when 'int=0' is declared, for the '{' , and for (i) after rows!!
Sorry. That was the way that a for loop is written in C#. Here is how it should look in vb.net
Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim balance As New frmBalance()
  3.  
  4. For i As Integer = 0 To objDS.Tables(0).Rows.Count - 1
  5.  
  6. If txtDisplay.Text = DirectCast(objDS.Tables(0).Rows(i)("PIN"), String) Then
  7.  
  8. Me.Hide()
  9.  
  10. balance.Show()
  11.  
  12. End If
  13.  
  14. Next
  15.  
  16.  
Nathan
Mar 14 '08 #8
Sorry. That was the way that a for loop is written in C#. Here is how it should look in vb.net
Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim balance As New frmBalance()
  3.  
  4. For i As Integer = 0 To objDS.Tables(0).Rows.Count - 1
  5.  
  6. If txtDisplay.Text = DirectCast(objDS.Tables(0).Rows(i)("PIN"), String) Then
  7.  
  8. Me.Hide()
  9.  
  10. balance.Show()
  11.  
  12. End If
  13.  
  14. Next
  15.  
  16.  
Nathan
thanks you've been a great help so far but its throwing up an error for line 5 saying:
Unable to cast object of type 'System.Int32' to type 'System.String'.
Mar 14 '08 #9
nateraaaa
663 Expert 512MB
Replace the , String with , System.Int32 and that should fix your problem. Basically it is saying PIN is an integer type and the code on line 5 is trying to retrieve a string.

Nathan
Mar 14 '08 #10
Replace the , String with , System.Int32 and that should fix your problem. Basically it is saying PIN is an integer type and the code on line 5 is trying to retrieve a string.

Nathan
hi nathan,

it worked. thanks for everthing
Mar 14 '08 #11
hi,

i've a new problem now. I trying to allow the user who entered their unique PIN to be able to view their bank balance. So Im trying to take their PIN and match it with their balance from my access database! I tried this but it doesnt work.

[CODE = .NET]

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

[/code]
Mar 14 '08 #12
nateraaaa
663 Expert 512MB
When you say it doesn't work what does that mean? Are you not getting any data back for the balance? Is the code throwing an error? You may want to use a try catch block in your code to catch an exceptions being thrown.

Nathan
Mar 17 '08 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: cooldv | last post by:
i am running a website on Windows 2000 server with ASP 3 webpages and Access 2000 database. (with a hosting company) traffic is slow at this time but expect to grow. lately i have been reading...
4
by: George Stout | last post by:
First off I do not know alot about writing queries to an Access Database from an ASP page. This is why I need help. I have an Events database for 6 colleges in our metro area. On the homepage I...
19
by: nospammmer | last post by:
Hello group, I have a rather general but interesting inquiry that is related to PHP and I hope this is the appropriate place to post it. I'm looking for a way to improve dramatically the...
6
by: Marvin Libson | last post by:
Hi All: I am running DB2 UDB V7.2 with FP11. Platform is Windows 2000. I have created a java UDF and trigger. When I update my database I get the following error: SQL1224N A database...
0
by: Alex | last post by:
Hi all, I've been running a db2 V8.1 databasle to store my radius server accounting info for a *long* time and have never had any problems with it. Last week we had a power outage in our...
5
by: Bec | last post by:
I'm in desperate need of your help.. I need to build an access database and have NO idea how to do this.. Not even where to start.. It IS for school, and am not asking anyone to do my...
12
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
18
by: surfrat_ | last post by:
Hi, I am having the following problems in getting Microsoft Visual Studio 2005 Professional to link to an Access .mdb database. Please help me to sort this out. Problem 1: The Microsoft...
12
by: grace | last post by:
i am wondering why my database retrieval becomes too slow...we set up a new server (ubuntu, breezy badger) machine where we transferred all our files from the old server.. Our new server uses Asus...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.