Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is the difference between Server.Transfer and
Response.Redirect? Why would you choose one over the other?

Answer Posted / a

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Runtime.InteropServices.ComTypes;
using System.Data.OleDb;
using System.IO;

public partial class ReadExcel : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
string strFilePath = @"D:\Development\Test.xlsx";
string strBatchPath = @"D:\Development\test.txt";
try {
string strConnectionString = string.Empty;
//strConnectionString =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
strFilePath + @";Extended Properties=""Excel
8.0;HDR=YES;IMEX=1""";
strConnectionString =
@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
strFilePath + @";Extended Properties=""Excel 12.0
Xml;HDR=YES;IMEX=1""";
OleDbConnection cnCSV = new OleDbConnection
(strConnectionString);
cnCSV.Open();
OleDbCommand cmdSelect = new OleDbCommand
(@"SELECT * FROM [Sheet1$]", cnCSV);
OleDbDataAdapter daCSV = new OleDbDataAdapter();
daCSV.SelectCommand = cmdSelect;
DataTable dtCSV = new DataTable();
daCSV.Fill(dtCSV);
cnCSV.Close();
daCSV = null;

StreamWriter sr = File.AppendText(strBatchPath);
string cmd = string.Empty;
for (int i = 0; i < dtCSV.Rows.Count; i++) {
cmd = "xcopy /Y \"" + dtCSV.Rows[i][0]
+ "\" " + "\"D:/\"";
WriteText(cmd, sr);
}
sr.Close();
} catch (Exception ex) {
} finally {
}
}

public void WriteText(string message, TextWriter tr) {
tr.WriteLine(message);
tr.Flush();
}
}

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is distributed system in asp.net?

978


What is a web api? Which protocol is used in a web api?

974


Explain Authentication mechanism in dotnet

1000


What is different authentication mechanisms used in ASP.NET?

1047


Describe the difference between inline and code behind - which is best in a?

1080


Which methods validate all the controls on a page?

919


What is cached data phone?

983


What is session handling in a webfarm, how it can work with its limits?

1067


What is State Management in .Net and how many ways are there to maintain a state in .Net? What is view state?

995


What is cross page posting? How is it done?

899


Explain why it is useful to use mvc instead of webforms? : asp.net mvc

986


Am not able to move the controls on the form freely in asp.net 3.5 even though I selected the position as relative or absolute for those controls. What should I do to overcome this?

2323


What are the advantages of using session?

846


How to implement Authentication and Authorization?

1007


Where sessions are stored?

1053