469,592 Members | 1,923 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,592 developers. It's quick & easy.

how do you get data from csv to windows form

Rob
Hi to all.
I am new to Visualbasic.net and windowz programming in general so I hope
someone can help.
I am trying to get info from a csv (Excell) file into a windows form.
For instance I want to get the totals of one "column" and put it into a
textbox on a form when I press a button. I did not think it would be
difficult to do , but I cant seem to get it right.
I have managed to get a datagrid working , using the oledbDataAdapter
,oledbconnection and Dataset stuff on the form with a MSAccess .mdb
file(More by luck than anything else) , but this is not really what I want.

Has anyone got a simple approch that accesses a csv file on say c:\data
\mycsvfile.csv and puts the total of the first column in a textbox
on a form , when I press a button. If I can get that working , I' may be
able to go from there.
I'm sure some query like: (Select count(*) from myfile.csv where column =
"something " ) , will be needed , but as I said I'm new to this stuff and I
may be barking up the wrong tree altogether.
Thanks
Rob
Nov 21 '05 #1
5 1629
Rob,

Mostly you can read your CSV file into a dataset.
http://groups.google.com/groups?selm...tngp13.phx.gbl

Than you can use within that the datatable.compute to get the total of the
column
http://msdn.microsoft.com/library/de...mputetopic.asp

You will not reads much code in my opinion.

I hope this helps?

Cor

"Rob" <ro****@hotmail.com>
Hi to all.
I am new to Visualbasic.net and windowz programming in general so I hope
someone can help.
I am trying to get info from a csv (Excell) file into a windows form.
For instance I want to get the totals of one "column" and put it into a
textbox on a form when I press a button. I did not think it would be
difficult to do , but I cant seem to get it right.
I have managed to get a datagrid working , using the oledbDataAdapter
,oledbconnection and Dataset stuff on the form with a MSAccess .mdb
file(More by luck than anything else) , but this is not really what I
want.

Has anyone got a simple approch that accesses a csv file on say c:\data
\mycsvfile.csv and puts the total of the first column in a textbox
on a form , when I press a button. If I can get that working , I' may be
able to go from there.
I'm sure some query like: (Select count(*) from myfile.csv where column =
"something " ) , will be needed , but as I said I'm new to this stuff and
I
may be barking up the wrong tree altogether.
Thanks
Rob

Nov 21 '05 #2
"Rob" <ro****@hotmail.com> schrieb:
I am trying to get info from a csv (Excell) file into a windows form.
For instance I want to get the totals of one "column" and put it into a
textbox on a form when I press a button. I did not think it would be
difficult to do , but I cant seem to get it right.
I have managed to get a datagrid working , using the oledbDataAdapter
,oledbconnection and Dataset stuff on the form with a MSAccess .mdb
file(More by luck than anything else) , but this is not really what I
want.


<URL:http://www.connectionstrings.com/>
-> "Text"

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3
Rob <ro****@hotmail.com> wrote in news:Xns95AAD35F4CA1robd00hotmailcom@
196.25.240.158:
I am trying to get info from a csv (Excell) file into a windows form.


Take a look at the Microsoft's ODBC Text Driver.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #4
rob
Thanks for the help guys , but I am still struggeling here. As I said
I'm new to this and I don't really have the background knowledge
needed.
I am trying to put a total for instance into a textbox. this is my
code.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim file As String = "Test.csv"
Dim path As String = "C:\"

Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & _ path & ";Extended
Properties=""Text;HDR=no;FMT=Delimited\"""

Dim conn As New OleDbConnection(ConStr)
Dim qwerty As New OleDb.OleDbCommand("Select count(*) from
test.csv " & file,conn)
TextBox1.Text = qwerty.ExecuteScalar '******BOMBS out
here****

End Sub
Formatting is not great here.
It seems to get as far as running the actual query then crashes. I can
get code like this to work on an .mdb file , but that has collumns
that are named etc. This csv file has nothing like that.If you open
the csv file in Excel the column's are "named" A to P , like a normal
spreadsheet.
I get a feeling my query may be badly structured , although I have
tried
lots of variations with the same result.
I have Microsoft ADO,net step by step , but nowhere does it mention
CSV files.

Any help appreciated
Cheers
Rob
"Cor Ligthert" <no************@planet.nl> wrote in message news:<#R**************@TK2MSFTNGP14.phx.gbl>...
Rob,

Mostly you can read your CSV file into a dataset.
http://groups.google.com/groups?selm...tngp13.phx.gbl

Than you can use within that the datatable.compute to get the total of the
column
http://msdn.microsoft.com/library/de...mputetopic.asp

You will not reads much code in my opinion.

I hope this helps?

Cor

"Rob" <ro****@hotmail.com>
Hi to all.
I am new to Visualbasic.net and windowz programming in general so I hope
someone can help.
I am trying to get info from a csv (Excell) file into a windows form.
For instance I want to get the totals of one "column" and put it into a
textbox on a form when I press a button. I did not think it would be
difficult to do , but I cant seem to get it right.
I have managed to get a datagrid working , using the oledbDataAdapter
,oledbconnection and Dataset stuff on the form with a MSAccess .mdb
file(More by luck than anything else) , but this is not really what I
want.

Has anyone got a simple approch that accesses a csv file on say c:\data
\mycsvfile.csv and puts the total of the first column in a textbox
on a form , when I press a button. If I can get that working , I' may be
able to go from there.
I'm sure some query like: (Select count(*) from myfile.csv where column =
"something " ) , will be needed , but as I said I'm new to this stuff and
I
may be barking up the wrong tree altogether.
Thanks
Rob

Nov 21 '05 #5
rob
Me again guys.
Got the problem sorted. I forgot to open the "@##$%%^" connection.
Starting to get some results now.
Cheers
Rob
"Cor Ligthert" <no************@planet.nl> wrote in message news:<#R**************@TK2MSFTNGP14.phx.gbl>...
Rob,

Mostly you can read your CSV file into a dataset.
http://groups.google.com/groups?selm...tngp13.phx.gbl

Than you can use within that the datatable.compute to get the total of the
column
http://msdn.microsoft.com/library/de...mputetopic.asp

You will not reads much code in my opinion.

I hope this helps?

Cor

"Rob" <ro****@hotmail.com>
Hi to all.
I am new to Visualbasic.net and windowz programming in general so I hope
someone can help.
I am trying to get info from a csv (Excell) file into a windows form.
For instance I want to get the totals of one "column" and put it into a
textbox on a form when I press a button. I did not think it would be
difficult to do , but I cant seem to get it right.
I have managed to get a datagrid working , using the oledbDataAdapter
,oledbconnection and Dataset stuff on the form with a MSAccess .mdb
file(More by luck than anything else) , but this is not really what I
want.

Has anyone got a simple approch that accesses a csv file on say c:\data
\mycsvfile.csv and puts the total of the first column in a textbox
on a form , when I press a button. If I can get that working , I' may be
able to go from there.
I'm sure some query like: (Select count(*) from myfile.csv where column =
"something " ) , will be needed , but as I said I'm new to this stuff and
I
may be barking up the wrong tree altogether.
Thanks
Rob

Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by juky | last post: by
6 posts views Thread by Tejpal Garhwal | last post: by
5 posts views Thread by John Bradley | last post: by
1 post views Thread by Angus Lepper | last post: by
7 posts views Thread by Andrew McKendrick | last post: by
3 posts views Thread by Uma sakshi | last post: by
10 posts views Thread by Doug Bell | last post: by
6 posts views Thread by Wesley Peace | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.