scorpion53061,
I'm not sure if you are thanking me or asking for more help! (year ends bite
;-) )
The Export routine I gave should do the job for you. Simply change two lines
that look like:
[color=blue][color=green]
> > delim = ","[/color][/color]
to[color=blue][color=green]
> > delim = ControlChars.Tab[/color][/color]
Then you can call the routine with:
[color=blue][color=green]
> > Export("scorpion53061.txt", dslist1.Tables(0))[/color][/color]
Well this isn't correct![color=blue][color=green]
> > Dim output As New StreamWriter(path, False,[/color]
> UnicodeEncoding.Default)[/color]
[color=blue][color=green]
> > You can change (or remove) the Encoding parameter above to suit your[/color]
> needs,[color=green]
> > I used Unicode as the table had non ASCII characters in it.[/color][/color]
I'm actually using the Encoding.Default property above, which gives me the
Win32 code page, which for this routine is more correct...
I would change the line to:[color=blue][color=green]
> > Dim output As New StreamWriter(path, False,[/color]
> Encoding.Default)[/color]
Hope this helps
Jay
"scorpion53061" <Its the end of the world as we know
it@here.com> wrote in
message news:ePaU6fL4DHA.2348@TK2MSFTNGP10.phx.gbl...[color=blue]
> Jay,
>
> I hope you dont mind and I promise I will help you out someday but right[/color]
now[color=blue]
> my brain is mush and year end is hours away.
>
> My dataset name is dslist1.Tables(0)
>
> I have to write a tab delimted text file of this dataset.
>
> The dataset is large.
>
> Thank you for your help!!
>
>
>
> "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in message
> news:%23z$ArYL4DHA.1272@TK2MSFTNGP11.phx.gbl...[color=green]
> > scorpion53061
> > Here's a quick VB.NET 1.1 export routine that is very general (too
> > general?):
> >
> > Its based on a DataSet, however you should be able to adopt it to a
> > DataReader instead.
> >
> > ' Required imports
> > Imports System.IO ' for the StreamWriter
> > Imports System.Text ' for the UnicodeEncoding
> >
> > ' sample usage
> > Export("Customers.csv", DataSet1.Tables("Customers"))
> > Export("Employees.csv", DataSet1.Tables("Employees"))
> >
> >
> > Public Sub Export(ByVal path As String, ByVal table As DataTable)
> > Dim output As New StreamWriter(path, False,[/color]
> UnicodeEncoding.Default)[color=green]
> > Dim delim As String
> >
> > ' Write out the header row
> > delim = ""
> > For Each col As DataColumn In table.Columns
> > output.Write(delim)
> > output.Write(col.ColumnName)
> > delim = ","
> > Next
> > output.WriteLine()
> >
> > ' write out each data row
> > For Each row As DataRow In table.Rows
> > delim = ""
> > For Each value As Object In row.ItemArray
> > output.Write(delim)
> > If TypeOf value Is String Then
> > output.Write(""""c) ' thats four double quotes and a[/color][/color]
c[color=blue][color=green]
> > output.Write(value)
> >
> > output.Write(""""c) ' thats four double quotes and a[/color][/color]
c[color=blue][color=green]
> > Else
> > output.Write(value)
> > End If
> > delim = ","
> > Next
> > output.WriteLine()
> > Next
> >
> > output.Close()
> >
> > End Sub
> >
> > You can change (or remove) the Encoding parameter above to suit your[/color]
> needs,[color=green]
> > I used Unicode as the table had non ASCII characters in it. Also when
> > writing strings, I don't deal with double quotes in the string. If you[/color]
> make[color=green]
> > the StreamWriter a parameter it will be much more flexible (you could go[/color]
> to[color=green]
> > a memory stream to support cut & paste). I use the default formatting[/color][/color]
for[color=blue][color=green]
> > numeric types.
> >
> > You can change it to use a DataView (for sorting & filtering for[/color][/color]
example)[color=blue]
> by[color=green]
> > changing the following lines:
> >
> > 'Public Sub Export(ByVal path As String, ByVal table As DataTable)
> > Public Sub Export(ByVal path As String, ByVal view As DataView)
> >
> > 'For Each col As DataColumn In table.Columns
> > For Each col As DataColumn In view.Table.Columns
> >
> > 'For Each row As DataRow In table.Rows
> > For Each row As DataRowView In view
> >
> > 'For Each value As Object In row.ItemArray
> > For Each value As Object In row.Row.ItemArray
> >
> > Instead of setting the delim variable to "," for comma delimited, you[/color][/color]
can[color=blue][color=green]
> > set it to ControlChars.Tab for tab delimited.
> >
> > Hope this helps
> > Jay
> >
> > "scorpion53061" <Its the end of the world as we know
it@here.com> wrote[/color][/color]
in[color=blue][color=green]
> > message news:OR4%23s9K4DHA.2480@TK2MSFTNGP09.phx.gbl...[color=darkred]
> > > Well I had a way to write an array to an excel spreadsheet but on a[/color][/color][/color]
huge[color=blue][color=green][color=darkred]
> > > time critical run it failed iwth the dreaded HRESULT: 0x800A03EC[/color][/color][/color]
error.[color=blue]
> It[color=green][color=darkred]
> > > worked fine when i sampled the data to go in but when it all tried to[/color][/color][/color]
go[color=blue][color=green]
> > in[color=darkred]
> > > it bombed.
> > >
> > > So I need to write this to a tab delimited file and I sure hope[/color][/color][/color]
somebody[color=blue][color=green]
> > is[color=darkred]
> > > awake tonight.
> > >
> > > How do I write my dataset to make a tab delimted text file?
> > >
> > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]