473,811 Members | 3,241 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 oledbDataAdapte r
,oledbconnectio n 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 1776
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.compu te 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 oledbDataAdapte r
,oledbconnectio n 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 oledbDataAdapte r
,oledbconnectio n 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.connections trings.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:Xns95AAD35 F4CA1robd00hotm ailcom@
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********@rog ers.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(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

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

Dim ConStr As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=" & _ path & ";Extended
Properties=""Te xt;HDR=no;FMT=D elimited\"""

Dim conn As New OleDbConnection (ConStr)
Dim qwerty As New OleDb.OleDbComm and("Select count(*) from
test.csv " & file,conn)
TextBox1.Text = qwerty.ExecuteS calar '******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******* *******@TK2MSFT NGP14.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.compu te 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 oledbDataAdapte r
,oledbconnectio n 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******* *******@TK2MSFT NGP14.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.compu te 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 oledbDataAdapte r
,oledbconnectio n 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
5792
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 modified that is to upgrade a big, more than 100,000 lines DOS based program developed by FoxPro 2.x to .NET platform. The design is as previous and the implementation will be reprogrammed. As a duty in my job I should find an answer about the
3
4065
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 appreciate. Thank you. Juky
6
6709
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
18312
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 just open http://mydomain.com/datapage.asp?recnum=25. I would like to read this data directly into a variable. I'm sure this is quite easy (as easy as Fileopen), but I just can't seem to find it.
1
2317
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: Public Class Form1 Inherits System.Windows.Forms.Form
7
4231
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 (DataBindings). - When I display a record and then try to access the .Text property of one of the text boxes on any tab except the current tab, the result is an Empty string.
3
2885
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 application or notepad where i want to paste it to be.How can i do it?If anyone knows source code or any website URL's please let me know. Umasakshi
10
1673
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 system. The system generally works quite well. Currently the User interface calls for a refresh of data every 15 minutes (selectable) and the Data Access Class connects to the DB and retrieves the
10
3276
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: MySqlAdapter.InsertCommand = New SqlCommand("INSERT INTO billing( type, dsc ) VALUES ( @type, @dsc)", MySqlConnection) But it gives me the following error when MySqlAdapter.Update(MyDt) executes: Must declare the variable '@type' Could someone tell me what I'm...
6
2426
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 connection string works fine and the tables are added to the project without a problem. When I create the tables they appear to bind and I am able to preview the data in the database in design mode; however, at runtime no data is displayed and the...
0
9604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10644
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10379
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10127
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7665
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4336
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.