473,404 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

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 1763
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Hamed | last post by:
Hello I have employed as a developer in a software company that its team uses FoxPro / VB 6.0 / VC++ 6.0 as the developing tools and newly is going to migrate to VS.NET. There is a project...
3
by: juky | last post by:
Hi all, I have 2 applications one in VB.net and the other in VC6. I need to pass data between them. How can I do it? what's the best way to implement such communication ? Any comment will be...
6
by: Tejpal Garhwal | last post by:
I have datagrid filled with some data rows. At the run time i want know how many total rows are there in the data grid ? Any idea ? Any Suggestions ? Thanks in advance Tej
5
by: John Bradley | last post by:
Toooo tired to look this one up. I have data that I need to acces in a small program. The data is accessable from an ASP webpage that I created myself. If I need to see data from record #25, I...
1
by: Angus Lepper | last post by:
I'm writing a stock ticker for a stock market simulation, and can load the data into the xmlreader in the first place, but can't figure out how to refresh/update the data in it. Any ideas? Code:...
7
by: Andrew McKendrick | last post by:
Hi, I've noticed a bug in VB.NET (latest .NET Framework)... - I have a TabControl on a form with several tabs. - Each tab contains text boxes that are bound to fields in a data source...
3
by: Uma sakshi | last post by:
Hi I have one VB.NET application,in that application i have one datagrid control.The datagrid control contains somedata.I want to copy the data in a particular cell and paste it into my C#.NET...
10
by: Doug Bell | last post by:
Hi, I have an application that has a "Data Access Class" and "User Interface Class". It is for receiving Purchase Order data from one system and pushing processed transactions to another...
10
by: cj | last post by:
I'm having a problem writing an insert command to work with a datatable. I've looked at what the sqldataadapter creates and created my insert command to look the same. I have:...
6
by: Wesley Peace | last post by:
I hate to cross post, but I've gotten no answer yet on a problem I'm having with visual studio 2008. I've created a series of forms with controls to access a Access database tables. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.