?
Solved

Array into Temp Files

Posted on 2005-03-08
3
Medium Priority
?
195 Views
Last Modified: 2010-04-23
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
…etc

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

Please help!

Thanks
-mack1er
0
Comment
Question by:mack1er
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
Wim_Bl earned 1500 total points
ID: 13488462
Hi,

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.

greetings
0
 

Author Comment

by:mack1er
ID: 13495946
Win_Bl,

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

Thanks in advance,
 -mack1er
0
 
LVL 9

Expert Comment

by:Wim_Bl
ID: 13508624
Hi,

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
dataAdapter.selectCommand.connection.open()
dataAdapter.fill(ds,"tblMyTable")
dataAdapter.selectCommand.connection.close()

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
next


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

greetings,
Wim
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question