|
-
Oct 9th, 2009, 07:41 AM
#1
Thread Starter
New Member
VB and database queries
I have an issue where I need to in a VB 2005 application call to an MSSQL database ( I already have the SQL figured out) and have the data returned put into a tabbed seperated values text file without using an array.
Can someone help me figure out this?
the data is for one value but the amount of names will vary over time.

Thank you
-
Oct 9th, 2009, 08:19 AM
#2
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.
-
Oct 9th, 2009, 08:19 AM
#3
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?
From my burrow, 2 feet under.
-
Oct 10th, 2009, 09:27 AM
#4
Thread Starter
New Member
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
-
Oct 10th, 2009, 09:39 AM
#5
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.
From my burrow, 2 feet under.
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
|