Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27225

VS 2010 How to retrieve several rows from database

$
0
0
Okay, so I've made a new project which allows users to send messages to each other. I've almost got it finished, just a few things need to be cleared up.

I've successfully allowed the user to send the message (via mysql). Now Im at the part where Im supposed to retrieve the message and display it in the form; this is where Im stuck. It'd be easy to do if the user has only 1 message in the database, but what if he had more than 1? How would I retrieve them all and display them in the form. Im using this query:

SELECT ToID FROM Message WHERE (ID LIKE @ID)

What it does is check the database for any messages containing the recipient as the user's ID. If the database does in fact contain any message, then the program will display them in the textboxes. But in the case if more than 1 message, how would the database display them in the form? The form has textboxes for: 1. Sender 2. Subject 3. Date.

This is the query I hoped to use for retrieving the message:

SELECT ID, Title, Body, Date, FromUsername FROM Message WHERE (ID LIKE @ID)

Please help? Any other solutions are fine as long as its easy to understand(im new to vb). Much appreciated!

Viewing all articles
Browse latest Browse all 27225

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>