finito
Nearly a Posting Virtuoso
1,321 posts since May 2010
Reputation Points: 60
Solved Threads: 135
Just do .Trim for each line.
finito
Nearly a Posting Virtuoso
1,321 posts since May 2010
Reputation Points: 60
Solved Threads: 135
Ok answer this for me. what is the Max space between the words or Data?
finito
Nearly a Posting Virtuoso
1,321 posts since May 2010
Reputation Points: 60
Solved Threads: 135
...if the lines are separated by CR/LF...
You could do something like this:
/*
* Open Database here
*/
StreamReader fileIn = new StreamReader(@"c:\science\Test.txt");
string strData = "";
List<string> lst_strRecords = new List<string>(33);
while (!fileIn.EndOfStream)
{
strData = fileIn.ReadLine();
if (string.IsNullOrEmpty(strData))
{
lst_strRecords.Add("");
continue;
}
if (strData.Contains((char)12))
{
PutRecordsInDatabase(lst_strRecords, dbConnection );
continue;
}
//
lst_strRecords.Add(strData);
}
//
fileIn.Close();
/*
* Close database here
*/
...which assumes your PutRecordsInDatabase() function will take an array of strings and an open database connection.
The PutRecordsInDatabase() would need to read each line of the string list and put it into the SQL or the parameters for the db update or insert.
Let me know if you need more specific code.
thines01
Postaholic
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402