What is the difference between Server.Transfer and
Response.Redirect? Why would you choose one over the other?
Answer Posted / d
using System.Data.OleDb;
string strFilePath = @"D:\Development\Test.xlsx";
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;
Response.Write(dtCSV.Rows.Count);
gvTest.DataSource = dtCSV;
gvTest.DataBind();
} catch (Exception ex) {
} finally {
}
<asp:GridView ID="gvTest" runat="server"
AutoGenerateColumns="false">
<Columns>
<asp:BoundField HeaderText="GDCID" DataField="GDCID" />
<asp:BoundField HeaderText="EmpID" DataField="EmpID" />
</Columns>
</asp:GridView>
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
How would you enable impersonation in the web.config file?
Explain how is a property designated as read-only?
What are the disadvantages of view state?
What are the security types in asp.net?
What are the differences between code behind and code inline?
Describe a Windows Service and its lifecycle ?
Explain how asp.net page works?
Write a code for sending an email from asp.net application.
Describe the difference between inline and code behind - which is best in a?
Can you explain one critical mapping? Performance issue which one is better?
Are there any resources for drop-in replacements for the default css that comes with the ASP.NET Website template?
Does web services support data reader like pom project?
What kind of data can be stored in viewstate?
What are the events in a page life cycle?
What is the difference between c# and .net?