Esempio n. 1
0
 private void AddParameters(SQLiteBulkInsert target)
 {
     target.AddParameter("ENTITEID", DbType.String);
     target.AddParameter("CODEID", DbType.String);
     target.AddParameter("MUNID", DbType.String);
     target.AddParameter("NUMERO_CIV", DbType.String);
     target.AddParameter("GENERIQUE", DbType.String);
     target.AddParameter("LIAISON", DbType.String);
     target.AddParameter("SPECIFIQUE", DbType.String);
     target.AddParameter("DIRECTION", DbType.String);
     target.AddParameter("ADDR_COMPLE", DbType.String);
     target.AddParameter("RUESID", DbType.String);
     target.AddParameter("GEOM", DbType.String);
 }
Esempio n. 2
0
 private void ReadGatFile(ref SQLiteConnection conn,String filepath,String SQLTableName)
 {
     SQLiteBulkInsert target = new SQLiteBulkInsert(conn, SQLTableName);
     AddParameters(target);
     if (conn.State == ConnectionState.Closed)
     {
         conn.Open();
     }
     System.IO.StreamReader sr = new System.IO.StreamReader(filepath);
     try
     {
         String line;
         line=sr.ReadLine(); //Read header
         List<String> headercols = new List<String>();
         line = line.Trim().Substring(1, line.Trim().Length - 2);
         String[] split = line.Split(new string[] { "\",\"" }, StringSplitOptions.None);
         foreach (string s in split)
         {
             headercols.Add(s);
         }
         do
         {
             line = sr.ReadLine();
             if (line.Length > 2)
             {
                 line = line.Substring(1, line.Length - 2);
             }
             string[] tmp = line.Split(new string[] { "\",\"" }, StringSplitOptions.None);
             target.Insert(new Object[] { tmp[headercols.IndexOf("ENTITEID")], tmp[headercols.IndexOf("CODEID")], tmp[headercols.IndexOf("MUNID")], tmp[headercols.IndexOf("NUMERO_CIV")], tmp[headercols.IndexOf("GENERIQUE")], tmp[headercols.IndexOf("LIAISON")], tmp[headercols.IndexOf("SPECIFIQUE")], tmp[headercols.IndexOf("DIRECTION")], tmp[headercols.IndexOf("ADR_COMPLE")], tmp[headercols.IndexOf("RUESID")], tmp[headercols.IndexOf("GEOM")] });
         }
         while (sr.EndOfStream == false);
         target.Flush();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         target.Rollback();
     }
     finally
     {
         if (conn.State != ConnectionState.Closed)
         {
             conn.Close();
         }
     }
 }