|
-
Mar 7th, 2009, 06:53 AM
#1
Thread Starter
New Member
Matching a textBox entry to a Primary Key in a DB table
Hi
I hope someone can help me. I have an ATM machine connected to a server. A form takes a textBox entry as a PIN number and matches it to a card number in the same table which is the primary key. The card number is in a comboBox.Selected Item. I have used a dataset to fill the comboBox as the form loads. I have tried for days and got nowhere. Any advice would be appreciated. Thanks
-
Mar 7th, 2009, 07:34 AM
#2
Frenzied Member
Re: Matching a textBox entry to a Primary Key in a DB table
What exactly are you trying to do?
-
Mar 7th, 2009, 08:30 AM
#3
Thread Starter
New Member
Re: Matching a textBox entry to a Primary Key in a DB table
Hi
Sorry I know it sounds really cofusing.
I have a database with 5 tables representing a banking system. I have a form which is supposed to represent the ATM machine. The form has a comboBox to display all the cards in the system which I have filled via a dataset. A textBox to enter a Pin number and a button to check the pin against the card number which is the primary key of the table they are both in.
Here is my problem. I am to match the pin to the card number in the same table using queries and I have failed after countless tries.
Thanks really despondent VB student.
Cally
-
Mar 7th, 2009, 08:41 AM
#4
Re: Matching a textBox entry to a Primary Key in a DB table
How did you fill the dataset that is in the combo? Are you using displaymember, valuemember?
What is the SQL that you wrote?
Can you post the code you are trying?
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Mar 7th, 2009, 09:11 AM
#5
Thread Starter
New Member
Re: Matching a textBox entry to a Primary Key in a DB table
In the tools menu of Visual Basic I dragged a SqlDataAdapter onto the form and the query is SELECLT cardNumber, AccountID, Confiscated, PIN FROM ATMCards. Then I generated a DataSet from the DataAdapter to hold the results.
In the code I then wrote on Form_Load SqlDataAdapter.Fill(DataSetCards.ATMcards)
M)
Now I have to write a command.Text query and the code to obtain a match for the PIN number to the cardNumber in the same table. I have tried quite a few queries and someone suggested an AddWithValue.
The SqlCommandText query is SELECT PIN FROM ATMCards WHERE cardNumber = @cardNumber. Now when I enter a pin number in the text box and select a card number from the comboBox I get an error message - Error: No mapping exists from object type system.Data.Row.View to a known managed native provider. I have used an SqlDataAdapter.DataReader to try and match the fields and this is the message I get.
Any advice would be welcome.
-
Mar 7th, 2009, 12:40 PM
#6
Re: Matching a textBox entry to a Primary Key in a DB table
MY advice (and I know other don't agree) is never use the generated datasets. I allways create my own objects.
But to your point I think
Dim strSQL As String = String.Empty
strSQL &= "Select Pin From ATMCards Where cardNumber = @cardNumber"
now create a connection object.
Create a command Oblect
create a parameter for the command object
parm.AddWithValue(@cardNumber,textbox.text)
execute scaler on the command object.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Mar 7th, 2009, 02:06 PM
#7
Thread Starter
New Member
Re: Matching a textBox entry to a Primary Key in a DB table
Thank you for taking the time to reply, I will get cracking with the code.
Cally
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|