Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB.Net --> DataSet to textfile!

Posted on 2006-10-19
5
Medium Priority
?
1,110 Views
Last Modified: 2008-02-01
I have a dataset that I need to write to a text file out on my server.

The text file will not exist and will need to have the current datetime timestamp in the name.  So, essentially,  I pull data from sql and create a series of datasets.  I need to output the datasets to text files that look like the following.

dataset1_currentdatetime.txt
dataset2_currentdatetime.txt
dataset3_currentdatetime.txt

Any and all information is so greatly appreciated...

0
Comment
Question by:ucic
[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
  • 3
  • 2
5 Comments
 
LVL 17

Expert Comment

by:ZeonFlash
ID: 17767790
You can output the a dataset's contents in XML format like this:

Dim strm As New IO.StreamWriter("C:\dataset1_" & Now.ToString("MM-dd-yyyy_HHmmtt") & ".txt", False, System.Text.Encoding.Unicode)
ds.WriteXml(strm)
0
 

Author Comment

by:ucic
ID: 17767927
Im already doing this in xml and it is not a feasible solution...

The project requires that the files get output directly to pipe delimited text files...

dak
0
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 2000 total points
ID: 17768031
In that case:

Dim strRow As String
Dim i As Integer
Dim strm As New IO.StreamWriter("C:\dataset1_" & Now.ToString("MM-dd-yyyy_HHmmtt") & ".txt", False, System.Text.Encoding.Unicode)

For Each dt As DataTable In ds.Tables
      For Each dr As DataRow In dt.Rows
            strRow = Nothing
            For Each col As DataColumn In dt.Columns
                  strRow &= dr(col) & "|"
            Next
            strRow = strRow.Remove(strRow.Length - 1, 1)
            strm.WriteLine(strRow)
      Next
Next

strm.Close()
0
 

Author Comment

by:ucic
ID: 17768082
Seems to create the text file, however...it seems to be create a pipe & tab delimeter...
Any ideas?
0
 

Author Comment

by:ucic
ID: 17768377
Got it figured out...I had a char datatype...All fixed...You Rock!
0

Featured Post

Technology Partners: 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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
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…

719 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