Help Text File

giulione Messages postés 2 Date d'inscription lundi 14 février 2005 Statut Membre Dernière intervention 26 juin 2006 - 26 juin 2006 à 18:37
cs_coq Messages postés 6349 Date d'inscription samedi 1 juin 2002 Statut Membre Dernière intervention 2 août 2014 - 26 juin 2006 à 22:21
Hi,
i have this text file
GENUARDI ADOLFO

90100

04800530828

VIA ORETO139

MARCHESE SALVATORE

90100

00464940824

IAZZA CARMINE 40

I must read 4 line each time  and put into a database so till the end of the document,
i wrote this code but is not right

try

{

StreamReader sr=

new StreamReader("\\Program Files\\SIP\\clienti.txt");

string[] After;

ArrayList lines =

new ArrayList();

string line;

int lineb=0;

int conta=0;

while ((line = sr.ReadLine()) !=
null)lines.Add(line);

if(conta % 4==0){

string a = (
string) lines[0];

string b = (
string) lines[1];

string c = (
string) lines[2];

string d = (
string) lines[3];SqlCeConnection cn =

new SqlCeConnection("Data Source=\\Program Files\\SIP\\data.sdf");cn.Open();

string gg="INSERT INTO clienti(nome,CAP,piva,Indirizzo) VALUES('"+a.ToString()+"','"+b.ToString()+"','"+c.ToString()+"','"+d.ToString()+"')";SqlCeCommand cmd =

new SqlCeCommand(gg,cn); cmd.ExecuteNonQuery();

cn.Close();

cont++;

}

}

catch(SqlCeException ex){

MessageBox.Show("Errore"+ex.Message+ex.Errors);

}
Please help me Bye

1 réponse

cs_coq Messages postés 6349 Date d'inscription samedi 1 juin 2002 Statut Membre Dernière intervention 2 août 2014 101
26 juin 2006 à 22:21
Hello,

You're on a French speaking forum.
Maybe you should try english ones.

/*
coq
MVP Visual C#
*/
0
Rejoignez-nous