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
Where the cookie value is stored?
When maintaining session through sql server, what is the impact of read and write operation on session objects?
Is post back property in asp net?
How can you display all validation messages in one control?
Is viewstate enabled by default?
Why the javascript validation not run on the asp.net button but run successfully on the html button?
Is asp.net and .net same?
Why asp.net is better than php?
To bind columns manually which tags do you need to add within the asp:datagrid ?
What setting must be added in the configuration file to deny a particular user from accessing the secured resources?
What is the used of "ispostback" property?
What is the difference between user control an custom control?
What is the difference between ASP.NET Webforms and ASP.NET MVC?
How to sign out from forms authentication?
What is form method?