G
Guest
I have a big problem with streamreader ReadLine()! I read from a long text
files about 13k lines, than I encounter a problem: ReadLine() is not anymore
able to go on! I have a string whose name is riga, where I put the return
value of Readline(), and this is what happens, when I read these three lines:
106933;;rosso;ivan
mauricio;3347614603;[email protected];1984-06-04;M;;;milano;CO;politecnico #
ingegneria;;;
106934;004008;rosso;carin;;[email protected];1982-04-03;F;;;;SE;bocconi;;;
106935;003785;rosso;luca;;[email protected];1984-03-10;M;;;;IE;iulm
- PR;;;
Riga assumes the following values:
"\t106933;;rosso;ivan
mauricio;3347614603;[email protected];1984-06-04;M;;;milano;CO;politecnico #
ingegneria;;; "
"\t106934;;rosso;ivan
mauricio;3347614603;[email protected];1984-06-04;M;;;milano;CO;politecnico #
ingegneria;;; "
"\t106935;;rosso;ivan
mauricio;3347614603;[email protected];1984-06-04;M;;;milano;CO;politecnico #
ingegneria;;; "
StreamReader.ReadLine() reads only the first part of the line, the
number...why? here is the code:
vwhile ((riga = flusso.ReadLine()) != null)
{
int iter = 0;
string[] campi = riga.Split(';');
progressBar1.PerformStep();
StringBuilder query = new StringBuilder("INSERT INTO TESSERE
VALUES(");
StringBuilder query2 = new StringBuilder("DELETE FROM
TESSERE WHERE Tessera=");
// query building
try
{
OleDbCommand cmd2 = new OleDbCommand(query2.ToString(),
conn);
cmd2.ExecuteReader();
OleDbCommand cmd = new OleDbCommand(query.ToString(),
conn);
cmd.ExecuteReader();
query2 = null;
query = null;
cmd = null;
cmd2 = null;
}
catch (System.Data.OleDb.OleDbException e)
{
continue;
}
}
The line where this happen is a line which raises an exception because it is
not in the right format(the following ones, instead, are in the right format
for the query to be built) but, in the text files, there are several lines
before where it happens, and the program is able to go on to the following
lines without problem! I can't see why here the ReadLine() stops...
Thanks
Eddy
files about 13k lines, than I encounter a problem: ReadLine() is not anymore
able to go on! I have a string whose name is riga, where I put the return
value of Readline(), and this is what happens, when I read these three lines:
106933;;rosso;ivan
mauricio;3347614603;[email protected];1984-06-04;M;;;milano;CO;politecnico #
ingegneria;;;
106934;004008;rosso;carin;;[email protected];1982-04-03;F;;;;SE;bocconi;;;
106935;003785;rosso;luca;;[email protected];1984-03-10;M;;;;IE;iulm
- PR;;;
Riga assumes the following values:
"\t106933;;rosso;ivan
mauricio;3347614603;[email protected];1984-06-04;M;;;milano;CO;politecnico #
ingegneria;;; "
"\t106934;;rosso;ivan
mauricio;3347614603;[email protected];1984-06-04;M;;;milano;CO;politecnico #
ingegneria;;; "
"\t106935;;rosso;ivan
mauricio;3347614603;[email protected];1984-06-04;M;;;milano;CO;politecnico #
ingegneria;;; "
StreamReader.ReadLine() reads only the first part of the line, the
number...why? here is the code:
vwhile ((riga = flusso.ReadLine()) != null)
{
int iter = 0;
string[] campi = riga.Split(';');
progressBar1.PerformStep();
StringBuilder query = new StringBuilder("INSERT INTO TESSERE
VALUES(");
StringBuilder query2 = new StringBuilder("DELETE FROM
TESSERE WHERE Tessera=");
// query building
try
{
OleDbCommand cmd2 = new OleDbCommand(query2.ToString(),
conn);
cmd2.ExecuteReader();
OleDbCommand cmd = new OleDbCommand(query.ToString(),
conn);
cmd.ExecuteReader();
query2 = null;
query = null;
cmd = null;
cmd2 = null;
}
catch (System.Data.OleDb.OleDbException e)
{
continue;
}
}
The line where this happen is a line which raises an exception because it is
not in the right format(the following ones, instead, are in the right format
for the query to be built) but, in the text files, there are several lines
before where it happens, and the program is able to go on to the following
lines without problem! I can't see why here the ReadLine() stops...
Thanks
Eddy