Array into Temp Files

Hello all,

I need to query a db and eventually split the data results into temp files.

I need to query a database based on three fields “myID”, “myTry” and “myDate”. Myid is a client id number, myTry is the number of times they have been contacted, and myDate is the particular time when a notification is set to go out.

I need to query the database once (select myID, myTry, myAmt, myItem from mytable where myDate = '" & txtMYDATE.text &"'). A user enters in myDate. I need to create an array that will split the data into groups:

All of the
myId's = 00001 and myTry = 1 need to be grouped together
myId's = 00001 and myTry = 2 need to be grouped together
myId's = 00002 and myTry = 1 need to be grouped together

Each result set needs to be written into temp files (csv, txt).

Please help!

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


create your recordset with this query:

select myID, myTry, myAmt, myItem from mytable where myDate = '" & txtMYDATE.text &"' group by myId, myTry order by myID

This will group your data.  Now write every record to a file, using a textWriter object. Eventually add a delimiter after each record. If you need help on how to loop through the recordset, please post your question under this comment.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mack1erAuthor Commented:

Thank you for pointing me in the right direction. Yes, I could use a little help looping through the recordset.

Thanks in advance,

this is the way I usually loop through a recordset (only started using VB.NET recently, so maybe there are better ways). I put my recordset in a dataSet object, say ds. I put the records in say tblMyTable. You also need an sql-statement and a connection object. The code is just off the top of my head, so there might (will?) be errors in it, but you'll get the idea.

dataAdapter.selectCommand.commandText = sql-statement
dataAdapter.selectCommand.connection = connection-object

The data you require is now in your dataSet. Looping through it:

dim dr as dataRow

for each dr in ds.tables("tblMyTable").Rows
     dim myID as integer
     dim myTry as integer

     myID = dr.item("myID")
     myTry = dr.item("myTry")
     .....  ' process the data here, for instance write it to a file

Hope this helps you out. As for the file-writing, don't know the syntax right away, so maybe google for it.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.