Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 6th, 2008, 06:51 AM
Registered User
 
Join Date: May 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Program c# reader .csv file and send to database

I must create an application consul who acquires me from rows .csv file only the data that are found in column 1 and those of column 4. To the data of column 1 in its turn it goes added to it ...1@example.com. To insert the acquired data in database..il a language of programming that I use is the c #. has advised to me to use foreach. thanks for the answers

 
Old May 6th, 2008, 12:34 PM
Authorized User
 
Join Date: Nov 2006
Posts: 93
Thanks: 0
Thanked 1 Time in 1 Post
Default

It's hard to tell what you are asking. If you are new to C# you might want to start with a good book like "Beginning Microsoft Visual C# 2008" or "Beginning C# 3.0: An Introduction to Object Oriented Programming" both from Wrox. Also you might try http://www.google.com/search?hl=en&q=C%23+Tutorials for a tutorial on C#.

If you can ask a more specific question people here will generally be glad to help.

What you don't know can hurt you!
 
Old May 6th, 2008, 04:32 PM
Registered User
 
Join Date: May 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ti spiego meglio quello che devo fare: devo creare un programma console dato una tabella .csv contenente 4 colonne e 5000 righe contenenti dei contatti..io devo prendere da questa tabella tramite c#sola la prima colonna e che rappresenta l'username e la quarta colonna che rappresenta la password per poi inviarli a un dato database..prima di inviare questi dati al database però io devo aggiungere a tutti i dati della colonna 1 ovvero gli username la dicitura ..@alice.it e poi procedere all'invio.. te ne sarei molto grato visto ke mi trovo in alto mare e nn so dove mettere le mani...grazie ancora x l'aiuto..ciao

 
Old May 6th, 2008, 04:36 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

This is an international forum, and AFAIK, most people here understand English but not Italian.... ;)

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old May 7th, 2008, 02:01 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Quote:
quote:Originally posted by mame37
 Ti spiego meglio quello che devo fare: devo creare un programma console dato una tabella .csv contenente 4 colonne e 5000 righe contenenti dei contatti..io devo prendere da questa tabella tramite c#sola la prima colonna e che rappresenta l'username e la quarta colonna che rappresenta la password per poi inviarli a un dato database..prima di inviare questi dati al database però io devo aggiungere a tutti i dati della colonna 1 ovvero gli username la dicitura ..@alice.it e poi procedere all'invio.. te ne sarei molto grato visto ke mi trovo in alto mare e nn so dove mettere le mani...grazie ancora x l'aiuto..ciao
Well it's a long time since I spoke Italian with any confidence but:
***********************************
I'll try to explain what I'm attempting: I need a console application that reads a CSV having 4 columns and 5000 rows, the first column is the username, the fourth the password. I need to add the email suffix @alice.it to the username and send the details to a database using C#. I find myself adrift on the high seas [may have misconstrued that] and appreciate your help, thanks etc.

*********************************************
Okay so I would attempt this in the following stages:
  • Read the file using TextReader and StreamReader: http://www.csharp-station.com/HowTo/...eTextFile.aspx
  • use String.Split to get an array representing the columns
  • Add the suffix to the first column
  • Pass the data to the database, you can use a stored procedure or SQL but you'll have to give more information. Is it a new table, an existing one etc?

--

Joe (Microsoft MVP - XML)
 
Old May 8th, 2008, 07:44 AM
Authorized User
 
Join Date: Nov 2006
Posts: 93
Thanks: 0
Thanked 1 Time in 1 Post
Default

Credo che il metodo preferito sarebbe quello di utilizzare un ciclo while piuttosto
che foreach.

Per esempio:
Code:
using (StreamReader sr = new StreamReader("TestFile.csv")) 
{
    String line;
    // Leggere e visualizzare righe dal file fino alla fine del file si è raggiunto.
    while ((line = sr.ReadLine()) != null) 
    {
        String[] arColonne = line.Split(",");


    }
}
What you don't know can hurt you!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need macro to send email via default mail program chutchinson Excel VBA 0 September 27th, 2007 09:28 PM
Import CSV files to Database in C# prasanna.nadgir C# 2 September 4th, 2007 11:03 AM
Excel File Reader Problem umair.hasan ASP.NET 1.0 and 1.1 Professional 0 August 17th, 2007 11:12 AM
Send Keystrokes to DOS Program from Access VBA Cosmos75 Access VBA 6 May 15th, 2007 06:24 PM
bookmark a PDF file with Acrobat Reader/OpenOffice crmpicco Need help with your homework? 0 February 27th, 2006 01:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.