string fullpathname = string.Empty;
if (FileUpload1.PostedFile.ContentLength > 0)
fullpathname = FileUpload1.PostedFile.FileName;
string conn = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source =" + fullpathname + ";Extended Properties='Excel 8.0;HDR=False;IMEX=1'";
OleDbConnection thisconnection = new OleDbConnection(conn);
thisconnection.Open();
string Sql = "select * from [Sheet1$]";
OleDbDataAdapter mycommand = new OleDbDataAdapter(Sql, thisconnection);
DataSet ds = new DataSet();
mycommand.Fill(ds, "[Sheet1$]");
thisconnection.Close();
int count = ds.Tables["[Sheet1$]"].Rows.Count;
for (int i = 0; i < count; i++)
{
string EnterID, tele;
EnterID = ds.Tables["[Sheet1$]"].Rows[i]["RestNo"].ToString().Trim();
tele = ds.Tables["[Sheet1$]"].Rows[i]["Tele"].ToString().Trim();
string excelsql = "update [tb_enterinfo] Set ContactTel='" + tele + "' Where EnterID='" + EnterID + "'";
SqlHelper.SqlExecNQ(excelsql);
}
if (FileUpload1.PostedFile.ContentLength > 0)
fullpathname = FileUpload1.PostedFile.FileName;
string conn = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source =" + fullpathname + ";Extended Properties='Excel 8.0;HDR=False;IMEX=1'";
OleDbConnection thisconnection = new OleDbConnection(conn);
thisconnection.Open();
string Sql = "select * from [Sheet1$]";
OleDbDataAdapter mycommand = new OleDbDataAdapter(Sql, thisconnection);
DataSet ds = new DataSet();
mycommand.Fill(ds, "[Sheet1$]");
thisconnection.Close();
int count = ds.Tables["[Sheet1$]"].Rows.Count;
for (int i = 0; i < count; i++)
{
string EnterID, tele;
EnterID = ds.Tables["[Sheet1$]"].Rows[i]["RestNo"].ToString().Trim();
tele = ds.Tables["[Sheet1$]"].Rows[i]["Tele"].ToString().Trim();
string excelsql = "update [tb_enterinfo] Set ContactTel='" + tele + "' Where EnterID='" + EnterID + "'";
SqlHelper.SqlExecNQ(excelsql);
}