using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.IO;
using Microsoft.Office.Interop.Excel;
using System.Reflection;
namespace Dashboard
{
public partial class Form1 : Form
{
public OleDbConnection con,con1;
public OleDbCommand cmd,cmd1;
public OleDbDataReader dr;
public OleDbDataAdapter db;
public string output3,output2,output4,output10,output11,output5,output6,output9,output7;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
try
{
con1 = new OleDbConnection(@"provider=Microsoft.Jet.OLEDB.4.0;data source=d:\rep2\uu.XLS;Extended Properties=Excel 8.0;");
con = new OleDbConnection(@"provider=Microsoft.Jet.OLEDB.4.0;data source=d:\rep2\tkgrp2.XLS;Extended Properties=Excel 8.0;");
cmd = new OleDbCommand("select * from [nave$]", con);
con.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{
string[] output1 = { dr.GetValue(1).ToString() };
string[] output8 = { dr.GetValue(0).ToString() };
for (int t = 0; t < output1.Length; t++)
{
output2 = output1[t].Substring(output1[t].IndexOf('(') + 1, output1[t].IndexOf(')') - output1[t].IndexOf('(') - 1);
output3 = output1[t].Substring(8, 5).ToString();
output4 = output1[t].Substring(0, 3).ToString();
output5 = output1[t].Substring(0, 16).ToString();
output10 = output1[t].Substring(3, 2).ToString();
output11 = output1[t].Substring(0, 3).ToString();
for (int t1 = 0; t1 < output8.Length; t1++)
{
output6 = output8[t].Substring(0, output8[t].IndexOf(' ') + 1);
output7 = output8[t].Substring(output8[t].IndexOf(' ') + 1);
output9 = output7.ToString();
//string str = "insert into [navv$] (DPC,TG_Number,Circle,Operators,UMG,TG_Name,Dates,Times) values('" + output3 + "','" + output2 + "','" + output4 + "','" + output10 + "','" + output11 + "','" + output5 + "','" + output6 + "','" + output9 + "')";
//OleDbDataAdapter data2 = new OleDbDataAdapter(str, con1);
//DataSet b = new DataSet();
//data2.Fill(b);
}
}
string str = "insert into [navv$] (DPC,TG_Number,Circle,Operators,UMG,TG_Name,Dates,Times) values('" + output3 + "','" + output2 + "','" + output4 + "','" + output10 + "','" + output11 + "','" + output5 + "','" + output6 + "','" + output9 + "')";
OleDbDataAdapter data2 = new OleDbDataAdapter(str, con1);
DataSet b = new DataSet();
data2.Fill(b);
}
cmd.Connection.Close();
MessageBox.Show("done");
}
catch (SystemException ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
please help me its urgent........