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
How you can access the values from the Repeater control in ASP.NET?
Can user control be stored in library?
How do u declare static variable and how it is declared and what is its lifetime?
Describe briefly what is the role of IIS on an ASP.NET application? What does it for the same application?
What is the difference between table and query?
Where the assembly is stored in asp.net?
Explain the advantages of caching?
How to implement globalization and localization in the use interface in .net.
How many types of cookies are there in asp.net?
what is a .xap file? Explain with an example.
Which protocol is used to call a web service?
What are the features that make asp.net more used framework? : asp.net mvc
What are the advantages of passport authentication?
Just by seeing the signature of the bean how can you specify whether it is a stateful or stateless session bean?
What is the use of session in web application?