Hee is the VB code and below is the ASPX code.
Imports System.Data.SqlClient
Imports System.Web.Configuration
Imports System.Web.UI
Partial Class admin_excel
Inherits System.Web.UI.Page
Dim strconnectionString As String =
WebConfigurationManager.ConnectionStrings("LocalSqlServer").ConnectionString
Dim con As New SqlConnection(strconnectionString)
Dim cmd As New SqlCommand("", con)
Dim recordcount As String
Dim stringWrite As New System.IO.StringWriter
Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Response.Clear()
Response.ContentType = "application/vnd.ms-excel"
Try
con.Open()
Dim myda As SqlDataAdapter
Dim ds As Data.DataSet
myda = New SqlDataAdapter("SELECT
gown_orders.StudentID,gown_studentinfo.FullName,gown_studentinfo.NRIC,gown_studentinfo.Gender
As Sex, gown_orders.GownSize As Size, gown_orders.Rental,
gown_orders.DeliveryOption As Delivery, gown_orders.HomeContact As
Contact, gown_orders.HPContact As Mobile,gown_orders.OrderDate,
gown_orders.IssueDate,gown_orders.Refunded, gown_studentinfo.School,
gown_studentinfo.Program, gown_studentinfo.GraduationSession FROM
gown_orders INNER JOIN gown_studentinfo ON gown_orders.StudentID =
gown_studentinfo.UserID", strconnectionString)
ds = New Data.DataSet
myda.Fill(ds, "AllTables")
GridViewOrderList.DataSource = ds.Tables(0)
GridViewOrderList.DataBind()
GridViewOrderList.RenderControl(htmlWrite)
Catch ex As Exception
con.Close()
Exit Try
Finally
con.Close()
End Try
End If
End Sub
End Class
============================================
Imports System.Data.SqlClient
Imports System.Web.Configuration
Imports System.Web.UI
Partial Class admin_excel
Inherits System.Web.UI.Page
Dim strconnectionString As String =
WebConfigurationManager.ConnectionStrings("LocalSqlServer").ConnectionString
Dim con As New SqlConnection(strconnectionString)
Dim cmd As New SqlCommand("", con)
Dim recordcount As String
Dim stringWrite As New System.IO.StringWriter
Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Response.Clear()
Response.ContentType = "application/vnd.ms-excel"
Try
con.Open()
Dim myda As SqlDataAdapter
Dim ds As Data.DataSet
myda = New SqlDataAdapter("SELECT
gown_orders.StudentID,gown_studentinfo.FullName,gown_studentinfo.NRIC,gown_studentinfo.Gender
As Sex, gown_orders.GownSize As Size, gown_orders.Rental,
gown_orders.DeliveryOption As Delivery, gown_orders.HomeContact As
Contact, gown_orders.HPContact As Mobile,gown_orders.OrderDate,
gown_orders.IssueDate,gown_orders.Refunded, gown_studentinfo.School,
gown_studentinfo.Program, gown_studentinfo.GraduationSession FROM
gown_orders INNER JOIN gown_studentinfo ON gown_orders.StudentID =
gown_studentinfo.UserID", strconnectionString)
ds = New Data.DataSet
myda.Fill(ds, "AllTables")
GridViewOrderList.DataSource = ds.Tables(0)
GridViewOrderList.DataBind()
GridViewOrderList.RenderControl(htmlWrite)
Catch ex As Exception
con.Close()
Exit Try
Finally
con.Close()
End Try
End If
End Sub
End Class
===============================================
Any ideas why Excel 2003 cannot open the file?
Thanks