Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reading a text file
Message
De
18/11/2005 05:39:43
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01070038
Message ID:
01070109
Vues:
12
>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform