>I'm trying to read a text file....and trying to insert some of the information into a DB but I cant seem to pick anything up, not sure what I'm doing wrong:
>
>TextReader file = new StreamReader(textBox1.Text.Trim());
>
>string line;
>for (int i = 1; i < counter; i++)
>{
>line = file.ReadLine();
>string upc = line.Substring(16,12);
>//call insert class
>Insert("insert into icchek (upc,item) values ('"+upc.Trim()+"',test");
>progressBar1.PerformStep();
>}
>
>
>Any help that would be great!
David,
You don't tell about anything where it fails. Anyway 2 things come to mind:
1) Substring(16,12). You are relying each line is at least 28 in length.
2) Within the Insert() the string you define doesn't have a closing parentheses. Your Insert() might be expecting like that but I suspect:
Insert("insert into icchek (upc,item) values ('"+upc.Trim()+"',test)");
If this is the reason I suggest you to use more readable String.Format. ie:
Insert( String.Format(
"insert into icchek (upc,item) values ('{0}',test)",
upc.Trim() ));
Cetin