Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Unnamed
Wednesday, January 17th, 2007 at 7:29:04pm MST 

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Data;
  5. using System.Data.Common;
  6. using System.Data.OleDb;
  7. using System.Data.SqlClient;
  8.  
  9. //Temp
  10. using System.Windows.Forms;
  11. using System.Diagnostics;
  12.  
  13. namespace cs_XQuest_TPMC.Common
  14. {
  15.     class rscImporter
  16.     {
  17.         DbProviderFactory DataFactory;
  18.         DbConnection DataConnection;
  19.         DbCommand DataCommand;
  20.         DbDataReader DataReader;
  21.  
  22.                 SqlConnection SQLConnection;
  23.                 SqlCommand SQLCommand;
  24.  
  25.                 DateTime DateStamp;
  26.  
  27.         public rscImporter()
  28.         {                     
  29.         }
  30.        
  31.         public void importFile(string fileType, string fileName)
  32.         {
  33.             if(fileType.ToUpper() == "EXCEL")
  34.             {
  35.                                 string Excel_connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'";
  36.  
  37.                 DataFactory = DbProviderFactories.GetFactory("System.Data.OleDb");
  38.                 DataConnection = DataFactory.CreateConnection();               
  39.                 DataConnection.ConnectionString = Excel_connectionString;             
  40.             }
  41.  
  42.                         SQLConnection = new SqlConnection(Properties.Settings.Default["TPMCSCString"].ToString());
  43.  
  44.                         if(Properties.app.Default["appDebug"].ToString().ToUpper() == "TRUE")
  45.                         {
  46.                                 //MessageBox.Show();
  47.                         }
  48.         }
  49.  
  50.         public void importMode(string importType)
  51.         {
  52.             if(importType == "LCC")
  53.             {
  54.                                 using (DataCommand = DataConnection.CreateCommand())
  55.                                 {
  56.                                         SQLCommand = SQLConnection.CreateCommand();
  57.                                        
  58.                                         DataCommand.CommandText = "SELECT citemcode, clcc FROM [LCC$]"; //SQL Statement
  59.  
  60.                                         DataConnection.Open();
  61.                                         SQLConnection.Open();
  62.  
  63.                                         using (DataReader = DataCommand.ExecuteReader())
  64.                                         {
  65.                                                 while (DataReader.Read())
  66.                                                 {
  67.                                                         if (DataReader["clcc"].ToString() != "")
  68.                                                         {
  69.                                                                 SQLCommand.CommandText = "INSERT INTO rscLCC (LocalCollectiveCode, SpecificCode)" +
  70.                                                                                                                 " VALUES ('" + DataReader["clcc"].ToString().Trim() + "', '" +
  71.                                                                                                                 DataReader["citemcode"].ToString().Trim() + "')";
  72.  
  73.                                                                 //MessageBox.Show(SQLCommand.CommandText);
  74.                                                                 DateStamp = DateTime.Now;
  75.                                                                 Debug.WriteLine("\n" + SQLCommand.CommandText);
  76.                                                                 Debug.WriteLine(DateStamp.ToString());
  77.                                                                 Debug.WriteLine(DataReader["clcc"].ToString().Trim());
  78.                                                                 Debug.WriteLine(DataReader["citemcode"].ToString().Trim());
  79.  
  80.                                                                 SQLCommand.ExecuteNonQuery();
  81.                                                                 Debug.WriteLine(SQLCommand.ExecuteNonQuery().ToString());
  82.                                                                 //Debug.WriteLine(dr["ID"].ToString());
  83.                                                         }
  84.                                                 }
  85.                                         }
  86.  
  87.                                         DataConnection.Close();
  88.                                         SQLConnection.Close();
  89.                                 }                         
  90.             }
  91.  
  92.                         if (importType == "LGC")
  93.                         {
  94.                         }
  95.  
  96.                         if (importType == "ActSpec")
  97.                         {
  98.                         }
  99.         }
  100.     }
  101. }

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right
worth-right
fantasy-obligation
fantasy-obligation