Re: VB and database queries
The fact that you say that you can't use an array indicates that this is an assignment of some sort, so I'm not going to write any code. What I will say is that you would use nested loops. You could read the data using a DataReader, in which case you'd use a Do or While loop to read the result set row by row and then inside that would be a For loop to read the row field by field.
Alternatively you could use a DataAdapter to populate a DataTable and then use nested For Each loops or a For loop inside a For Each loop.
If you won't be using the data again after that I'd suggest the first open. You can open the FAQ thread at the top of the Database Development forum and follow the link to my ADO.NET code examples thread. I believe it includes an example of a DataReader with nested loops.
Re: VB and database queries
Do you know how to write to a text file?
Do you know how to read data returned from a database query?
Re: VB and database queries
This is not an assignment, but the application will be in WIL after the fact and WIL does not allow array input to the input box. As I am trying to understand the concept I am attempting to do this in vb so then I can get my head around it.
I do know arrays in vb, but arrays and database are the two worst items in coding for me. I am not really lookiong for code, just an explaination of how to return to a text file from SQL query
thank you
Re: VB and database queries
Here's an article on how to create, and write to a text file:
http://www.startvbdotnet.com/files/default.aspx
Here's an intro on ADO.Net:
http://www.vbforums.com/showthread.php?t=466658
Basically, you'll want to use ADO.Net to read the database, and then the Filestream, and Streamwriter classes to write each record's information to your text file.