PC Review


Reply
Thread Tools Rate Thread

Display csv data in VB.net

 
 
Microsoft
Guest
Posts: n/a
 
      28th Oct 2004
I have a program that creates out put in the form of a CSV.. Basically a
text file with entries that look like this 1,2,3,4

Is there a control or way that I could display the information in a nice
table format directly on my VB form, without having to have Excel open a
file .. Thanks!


 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      28th Oct 2004
"Microsoft" <(E-Mail Removed)> schrieb:
>I have a program that creates out put in the form of a CSV..
> Basically a text file with entries that look like this 1,2,3,4


Take a look at <URL:http://www.connectionstrings.com/>. You'll find
connection strings for accessing CSV files in the "Text" section there. If
you have read the data into a dataset, you can bind it to a datagrid, for
example.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

 
Reply With Quote
 
Tom
Guest
Posts: n/a
 
      28th Oct 2004
I'll be interested to see how others answer this but here's my method.

'Open a connection using the Jet engine telling it to work with a text
file.

Dim cnText As New
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\MyData;Extended Properties=Text")

'Then read it with a data adapter or data reader.

cnText.Open()
Dim cmdTextSelect As New System.Data.OleDb.OleDbCommand("Select * from
MyFile.txt", cnText)
Dim drText As OleDbDataReader = cmdTextSelect.ExecuteReader()


You'll need a schema.ini file to define the text file. See this MSDN page.

http://msdn.microsoft.com/library/de...a_ini_file.asp

And BTW if you want text instead of numbers you many find this
undocumented parameter useful.

TextDelimiter='


Tom



Microsoft wrote:
> I have a program that creates out put in the form of a CSV.. Basically a
> text file with entries that look like this 1,2,3,4
>
> Is there a control or way that I could display the information in a nice
> table format directly on my VB form, without having to have Excel open a
> file .. Thanks!
>
>

 
Reply With Quote
 
Paul Clement
Guest
Posts: n/a
 
      28th Oct 2004
On Thu, 28 Oct 2004 11:29:40 -0400, "Microsoft" <(E-Mail Removed)> wrote:

¤ I have a program that creates out put in the form of a CSV.. Basically a
¤ text file with entries that look like this 1,2,3,4
¤
¤ Is there a control or way that I could display the information in a nice
¤ table format directly on my VB form, without having to have Excel open a
¤ file .. Thanks!
¤

You can use a DataGrid and ADO.NET:

Dim ConnectionString As String
Dim SQLString As String

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=e:\My Documents\TextFiles;" & _
"Extended Properties=""Text;HDR=NO;"""

SQLString = "Select * from ReportFile.txt"

Dim ConnectionText As New OleDb.OleDbConnection
ConnectionText.ConnectionString = ConnectionString

ConnectionText.Open()

Dim AdapterText As New OleDb.OleDbDataAdapter(SQLString, ConnectionText)

Dim DataSetText As New DataSet("TextFiles")
AdapterText.Fill(DataSetText, "TextFile")
DataGrid1.SetDataBinding(DataSetText, "TextFile")

ConnectionText.Close()


Paul ~~~ (E-Mail Removed)
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
=?Utf-8?B?Z3V5?=
Guest
Posts: n/a
 
      29th Oct 2004
If there isnt too much data you could
read the file into a string,
call Split on it to build an array
copy the array into the display control of your choice - combo, listbox or
wahtever

hth

guy

"Microsoft" wrote:

> I have a program that creates out put in the form of a CSV.. Basically a
> text file with entries that look like this 1,2,3,4
>
> Is there a control or way that I could display the information in a nice
> table format directly on my VB form, without having to have Excel open a
> file .. Thanks!
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Not plot a data series in a chart but still display in data table mebp Microsoft Excel Charting 1 19th Mar 2010 05:13 PM
Powerpoint display is cut off on data projector display. David-DEC Microsoft Powerpoint 1 16th Jan 2008 04:09 PM
Data Access Page: How do I display data from a filtered table? =?Utf-8?B?Sm9uYXRoYW4=?= Microsoft Access 0 9th Feb 2007 11:56 AM
Displaying Xml data in Treeview & AfterSelecting nodes display data in RichTextBox Guest Microsoft Dot NET 0 20th May 2005 08:13 AM
using Crystal Reports to display data in my dataset correctly (display the data I selected instead of all the data in table) JK Microsoft C# .NET 1 6th Sep 2003 10:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:24 PM.