Code:
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);
Debug.WriteLine("\n" + SQLCommand.CommandText);
Debug.WriteLine(DataReader["clcc"].ToString().Trim());
Debug.WriteLine(DataReader["citemcode"].ToString().Trim());
SQLCommand.ExecuteNonQuery();
//Debug.WriteLine(dr["ID"].ToString());
}
}
}
DataConnection.Close();
SQLConnection.Close();
}
}
The program run with no error. But after it complete the running my database is still empty. I am wandering why the data are not inserted into my table.
please advise.
Signed By Ionix