EDN Admin
Well-known member
I am binding txt files into SQL Database. There are 14 columns in my table. I want to exclude the lines whose username is "-". How can I apply it following codes? My user name columns number is 7 (@Column7).
Thanks in advance..String[] itemss = (File.ReadLines(currentFile)).Where(x => !x.StartsWith("#", StringComparison.CurrentCulture) && x.Contains("GET") && !x.Contains("SP_search") && (x.Contains(".pp") || x.Contains(".do") || x.Contains(".xl") || x.Contains(".pdf")) && !x.Contains(".dll")).ToArray();
for (int i = 0; i < itemss.Length; i++)
{
string[] items = itemss.Split(new char[] { });
Console.WriteLine(itemss);
nonqueryCommand.Parameters["@column1"].Value = items[0];
nonqueryCommand.Parameters["@column2"].Value = items[1];
nonqueryCommand.Parameters["@column3"].Value = items[2];
nonqueryCommand.Parameters["@column4"].Value = items[3];
nonqueryCommand.Parameters["@column5"].Value = items[4];
nonqueryCommand.Parameters["@column6"].Value = items[5];
nonqueryCommand.Parameters["@column7"].Value = items[6];
nonqueryCommand.Parameters["@column8"].Value = items[7];
nonqueryCommand.Parameters["@column9"].Value = items[8];
nonqueryCommand.Parameters["@column10"].Value = items[9];
nonqueryCommand.Parameters["@column11"].Value = items[10];
nonqueryCommand.Parameters["@column12"].Value = items[11];
nonqueryCommand.Parameters["@column13"].Value = items[12];
nonqueryCommand.Parameters["@column14"].Value = items[13];
//nonqueryCommand.Parameters["@column15"].Value = items[14];
nonqueryCommand.ExecuteNonQuery();
}
KAdir
View the full article
Thanks in advance..String[] itemss = (File.ReadLines(currentFile)).Where(x => !x.StartsWith("#", StringComparison.CurrentCulture) && x.Contains("GET") && !x.Contains("SP_search") && (x.Contains(".pp") || x.Contains(".do") || x.Contains(".xl") || x.Contains(".pdf")) && !x.Contains(".dll")).ToArray();
for (int i = 0; i < itemss.Length; i++)
{
string[] items = itemss.Split(new char[] { });
Console.WriteLine(itemss);
nonqueryCommand.Parameters["@column1"].Value = items[0];
nonqueryCommand.Parameters["@column2"].Value = items[1];
nonqueryCommand.Parameters["@column3"].Value = items[2];
nonqueryCommand.Parameters["@column4"].Value = items[3];
nonqueryCommand.Parameters["@column5"].Value = items[4];
nonqueryCommand.Parameters["@column6"].Value = items[5];
nonqueryCommand.Parameters["@column7"].Value = items[6];
nonqueryCommand.Parameters["@column8"].Value = items[7];
nonqueryCommand.Parameters["@column9"].Value = items[8];
nonqueryCommand.Parameters["@column10"].Value = items[9];
nonqueryCommand.Parameters["@column11"].Value = items[10];
nonqueryCommand.Parameters["@column12"].Value = items[11];
nonqueryCommand.Parameters["@column13"].Value = items[12];
nonqueryCommand.Parameters["@column14"].Value = items[13];
//nonqueryCommand.Parameters["@column15"].Value = items[14];
nonqueryCommand.ExecuteNonQuery();
}
KAdir
View the full article