Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get a text file into a Dataset
Message
De
05/04/2007 09:16:28
Sergio Ortiz
Tek Services Group, Llc
Hollywood, Floride, États-Unis
 
 
À
03/04/2007 09:56:50
John Baird
Coatesville, Pennsylvanie, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
01211619
Message ID:
01212415
Vues:
11
Hello John, thanks for your help.

I tried you code and with minor modifications I was able to read the comma delimited text file and put it into a Datatable.

Here is how:
string colString;
string[] strItems = null;
DataRow dr = null;
TextReader tr = null;
try
 {
  DataTable dtMyTable = new DataTable();
  dtMyTable.Columns.Add("CtrlPn", typeof(String));
  dtMyTable.Columns.Add("nAmount", typeof(Double));
  dtMyTable.Columns.Add("CheckNum", typeof(String));
  dtMyTable.Columns.Add("CheckType", typeof(String));

  string filePath = @"C:\Program Files\UPCI\ExportWachovia\CPRun99_2.run";
  tr = File.OpenText(filePath);
  colString = tr.ReadLine();
  colString = colString.Trim();
  while ( colString != null )
   {
    if (colString.Length > 0)
     {
       strItems = colString.Split(",".ToCharArray());
       dr = dtMyTable.NewRow();
       dr["CtrlPn"] = strItems[0];
       dr["nAmount"] = strItems[1];
       dr["CheckNum"] = strItems[2];
       dr["CheckType"] = strItems[3];
       dtMyTable.Rows.Add(dr);
     } //if
     colString = tr.ReadLine();

   }   //while ( colString != null )
}   //try
catch (Exception ex)
 {
   MessageBox.Show(ex.Message);
 }
I will post a new tread since I would like to get opinions about the best way to proceed with my task.
Here is the situation ( foxpro thinking ) :
Now that I have the comma delimited text file on a Datatable (dtMyTable ) I need to search for each of the records in the dtMyTable against a free foxpro table called Policy. If I found a match then retrieve information from this Policy table ( control number ) and then insert a record in a foxpro table called Transactions(insert into Trasnactions (controlnumber, .....).
Also before I insert the records into the transaction I will have to prepare/massage the data in the dtMyTable Datatable for insertion into the foxpro Transaction table.


Now here is my troubles since I'm new to ADO.NET.
What is the best way to interface with the free foxpro tables.
Do I load all the tables(policy, transaction) to a Dataset and then I seek on this Policy table, update some policy fields and insert into Transaction table. Once I am finished I sent the changes to the free table.
The Transaction foxpro free table contains 2.5 million records and Policy table has close to a million records.

Or

I can send select statements just to bring the records that match from the Policy table( like a seek )? Then once I get the match prepare the data and insert the record into the transaction table.
I guess this is the most logical way( looks like I have found the best way).



Anyfeed back is appreciated.
Sergio
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform