G
gloria
So I am writing data from a datastream to a filestream. The count of
rows in the datastream is 416. I count as I write to the filestream
and again I get 416. However, when I open the file, there are only 392
rows. What happened? Where are my missing rows? Are there limits to
using filestreams?
Thoughts?
--gloria
-------------------------------------
StreamWriter outputfileSW = File.CreateText(filenameStr);
string extractpartsStr = "select ..." ;
try
{
OleDbConnection extractpartsCN = new
OleDbConnection(extractbpmClass.strConn);
OleDbDataAdapter extractpartsDA = new
OleDbDataAdapter(extractpartsStr,extractpartsCN);
DataSet extractpartsDS = new DataSet();
extractpartsDA.Fill(extractpartsDS);
string subinvStr, partnumStr, descStr, serializedflagStr,
statusStr, hscodeStr;
string cooStr, newpartflagStr, BAXLineStr;
string tab = "\t";
int serializedInt, newpartInt;
DataTable build888Table = extractpartsDS.Tables[0];
int totalrows = build888Table.Rows.Count;
int countrows = 0;
foreach(DataRow build888Row in build888Table.Rows)
{
subinvStr = build888Row["SubInv"].ToString();
partnumStr = build888Row["PartNum"].ToString();
descStr = build888Row["PartDescr"].ToString();
serializedflagStr = build888Row["SerialFlag"].ToString();
statusStr = build888Row["Status"].ToString();
hscodeStr = build888Row["HSCode"].ToString();
cooStr = build888Row["COO"].ToString();
newpartflagStr = build888Row["NPFlag"].ToString();
if (serializedflagStr == "False")
serializedInt = 1;
else
serializedInt = 0;
if (newpartflagStr == "False")
newpartInt = 1;
else
newpartInt = 0;
BAXLineStr = subinvStr + tab + partnumStr + tab + descStr + tab +
//13 tabs
tab + tab + tab + tab + tab + tab +
tab + tab + tab + tab + tab + tab +
tab +
serializedInt + tab + statusStr + tab +
tab +
hscodeStr + tab + cooStr + tab +
//37 tabs
tab + tab + tab + tab + tab + tab +
tab + tab + tab + tab + tab + tab +
tab + tab + tab + tab + tab + tab +
tab + tab + tab + tab + tab + tab +
tab + tab + tab + tab + tab + tab +
tab + tab + tab + tab + tab + tab +
tab +
newpartInt;
outputfileSW.WriteLine(BAXLineStr);
countrows = countrows+1;
}
Console.WriteLine("\ttotalrows: " + totalrows);
Console.WriteLine("\n\tcountrows: " + countrows);
rows in the datastream is 416. I count as I write to the filestream
and again I get 416. However, when I open the file, there are only 392
rows. What happened? Where are my missing rows? Are there limits to
using filestreams?
Thoughts?
--gloria
-------------------------------------
StreamWriter outputfileSW = File.CreateText(filenameStr);
string extractpartsStr = "select ..." ;
try
{
OleDbConnection extractpartsCN = new
OleDbConnection(extractbpmClass.strConn);
OleDbDataAdapter extractpartsDA = new
OleDbDataAdapter(extractpartsStr,extractpartsCN);
DataSet extractpartsDS = new DataSet();
extractpartsDA.Fill(extractpartsDS);
string subinvStr, partnumStr, descStr, serializedflagStr,
statusStr, hscodeStr;
string cooStr, newpartflagStr, BAXLineStr;
string tab = "\t";
int serializedInt, newpartInt;
DataTable build888Table = extractpartsDS.Tables[0];
int totalrows = build888Table.Rows.Count;
int countrows = 0;
foreach(DataRow build888Row in build888Table.Rows)
{
subinvStr = build888Row["SubInv"].ToString();
partnumStr = build888Row["PartNum"].ToString();
descStr = build888Row["PartDescr"].ToString();
serializedflagStr = build888Row["SerialFlag"].ToString();
statusStr = build888Row["Status"].ToString();
hscodeStr = build888Row["HSCode"].ToString();
cooStr = build888Row["COO"].ToString();
newpartflagStr = build888Row["NPFlag"].ToString();
if (serializedflagStr == "False")
serializedInt = 1;
else
serializedInt = 0;
if (newpartflagStr == "False")
newpartInt = 1;
else
newpartInt = 0;
BAXLineStr = subinvStr + tab + partnumStr + tab + descStr + tab +
//13 tabs
tab + tab + tab + tab + tab + tab +
tab + tab + tab + tab + tab + tab +
tab +
serializedInt + tab + statusStr + tab +
tab +
hscodeStr + tab + cooStr + tab +
//37 tabs
tab + tab + tab + tab + tab + tab +
tab + tab + tab + tab + tab + tab +
tab + tab + tab + tab + tab + tab +
tab + tab + tab + tab + tab + tab +
tab + tab + tab + tab + tab + tab +
tab + tab + tab + tab + tab + tab +
tab +
newpartInt;
outputfileSW.WriteLine(BAXLineStr);
countrows = countrows+1;
}
Console.WriteLine("\ttotalrows: " + totalrows);
Console.WriteLine("\n\tcountrows: " + countrows);