- Unnamed
- Wednesday, January 17th, 2007 at 7:29:04pm MST
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Data;
- using System.Data.Common;
- using System.Data.OleDb;
- using System.Data.SqlClient;
- //Temp
- using System.Windows.Forms;
- using System.Diagnostics;
- namespace cs_XQuest_TPMC.Common
- {
- class rscImporter
- {
- DbProviderFactory DataFactory;
- DbConnection DataConnection;
- DbCommand DataCommand;
- DbDataReader DataReader;
- SqlConnection SQLConnection;
- SqlCommand SQLCommand;
- DateTime DateStamp;
- public rscImporter()
- {
- }
- public void importFile(string fileType, string fileName)
- {
- if(fileType.ToUpper() == "EXCEL")
- {
- string Excel_connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'";
- DataFactory = DbProviderFactories.GetFactory("System.Data.OleDb");
- DataConnection = DataFactory.CreateConnection();
- DataConnection.ConnectionString = Excel_connectionString;
- }
- SQLConnection = new SqlConnection(Properties.Settings.Default["TPMCSCString"].ToString());
- if(Properties.app.Default["appDebug"].ToString().ToUpper() == "TRUE")
- {
- //MessageBox.Show();
- }
- }
- public void importMode(string importType)
- {
- if(importType == "LCC")
- {
- using (DataCommand = DataConnection.CreateCommand())
- {
- SQLCommand = SQLConnection.CreateCommand();
- DataCommand.CommandText = "SELECT citemcode, clcc FROM [LCC$]"; //SQL Statement
- DataConnection.Open();
- SQLConnection.Open();
- using (DataReader = DataCommand.ExecuteReader())
- {
- while (DataReader.Read())
- {
- if (DataReader["clcc"].ToString() != "")
- {
- SQLCommand.CommandText = "INSERT INTO rscLCC (LocalCollectiveCode, SpecificCode)" +
- " VALUES ('" + DataReader["clcc"].ToString().Trim() + "', '" +
- DataReader["citemcode"].ToString().Trim() + "')";
- //MessageBox.Show(SQLCommand.CommandText);
- DateStamp = DateTime.Now;
- Debug.WriteLine("\n" + SQLCommand.CommandText);
- Debug.WriteLine(DateStamp.ToString());
- Debug.WriteLine(DataReader["clcc"].ToString().Trim());
- Debug.WriteLine(DataReader["citemcode"].ToString().Trim());
- SQLCommand.ExecuteNonQuery();
- Debug.WriteLine(SQLCommand.ExecuteNonQuery().ToString());
- //Debug.WriteLine(dr["ID"].ToString());
- }
- }
- }
- DataConnection.Close();
- SQLConnection.Close();
- }
- }
- if (importType == "LGC")
- {
- }
- if (importType == "ActSpec")
- {
- }
- }
- }
- }
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.
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.