AJ26
AJ26

Reputation: 501

How to return multiple database values to textboxes?

I currently have a test database with multiple values. In this example below it is data being returned from a SELECT query.

  Barcode      Product number   Pack_size
95587056212     0100-505621     1.000000
100955870562    0100-505621     0.000000
10095587056219  0100-505621     0.000000
10095587556214  0100-505621     12.000000

What I am trying to do is trying to return values with multiple instances to different textboxes. To explain further, let's say I have one textBox and I run a query that says:

SELECT * FROM bdorf where product number = '0100-505621' 

It would return the above mentioned data in a SQL environment because there are multiple instances because there are different "Barcodes" and "Pack_Sizes" but as it relates to my Winforms c# application, am not sure how to do this. Typically that query would be ran and I would let it say return a value to a textBox but as we know it would only pull one data as it is only pointing to one textBox. To give a live scenario of what am saying. Let's say I type in the same product number as above which is "0100-505621" as used previously in my example above. Above we saw it had 3 instances but in my application below you would see it returns only one because it is only pointing to one textBox:

enter image description here

What am still figuring out is how would I make it point to multiple textBoxes regardless of the product number entered?

I had in my mind that there are a maximum of 5 possible instances as that is the data in my test database. So I was thinking of starting off with 5 textBoxes and then tying the multiple instances possible to each one and anyone that misses(having let's say 3 instances) would return 0 to those textBoxes. Am not sure if am thinking about this correctly. I welcome suggestions

Upvotes: 2

Views: 331

Answers (2)

Javy26
Javy26

Reputation: 385

Why not use a datagrid instead? This would have you filter multiple results. It would be particularly good because I am guessing you don't have a clear idea on how much data will be passed. So create your datagrid. Then add textboxes to edit the values of that datagrid. Because ultimately it is just database values you are really updating.

Upvotes: 1

Javy26
Javy26

Reputation: 385

You could try using a GridView and list all the items from the database and add some textBoxes as filters at the top and search for each respective column you would want to filter on. If you want to edit the data by way of update,insert delete then you could add some check boxes below that GridView which also has buttons labelled: "insert,update, delete" which would have the necessary queries pointing to your database on what action to take. Am not really knowledgeable on GridView but I think that could work to some extent.

Upvotes: 1

Related Questions