把datagrid中的5萬多條記錄導出到一個excel表時出錯.請問要怎樣解決呀.

nnh 2004-03-26 04:41:26
導出時,網頁執行很慢,不過最后還是不成功.

出錯提示為:
Server Application Unavailable

The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser to retry your request.

Administrator Note: An error message detailing the cause of this specific request failure can be found in the application event log of the web server. Please review this log entry to discover what caused this error to occur.

請問要怎樣才能把這5萬條記錄導出呀?
...全文
30 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
huangwangman 2004-04-07
  • 打赏
  • 举报
回复
看看net_lover的吧
xubinhui 2004-04-07
  • 打赏
  • 举报
回复
http://www.eggheadcafe.com/articles/20021012.asp
nnh 2004-03-29
  • 打赏
  • 举报
回复
up
nnh 2004-03-27
  • 打赏
  • 举报
回复
up
nnh 2004-03-26
  • 打赏
  • 举报
回复
<%@ Page Language="VB" AutoEventWireup="True" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Color" %>

<html>
<script runat="server">
dim MyConnection as OleDbConnection
dim cmdSelect as OleDbCommand
dim dtrReader as OleDbDataReader
Sub Page_Load(sender As Object, e As EventArgs)
MyConnection = New OleDbConnection( "Provider=Microsoft.Jet.OLEDB.4.0; Data Source =" + Server.MapPath(".")+"/datagrid.mdb")
If Not IsPostBack Then
BindGrid()
End If
End Sub

Sub BindGrid()
Dim MyCommand As OleDbDataAdapter = new OleDbDataAdapter("select * from [news]", MyConnection)
Dim DS As DataSet = new DataSet()
MyCommand.Fill(DS,"min")
MyDataGrid.DataSource =DS.Tables("min").DefaultView
MyDataGrid.DataBind()
End Sub

Sub Mydatagrid_PageIndexChanged(s as object,e as DataGridPageChangedEventargs)
MyDataGrid.CurrentPageIndex=e.newPageIndex
BindGrid()
End Sub

Sub Button1_Click(sender As Object, e As System.EventArgs)
'-------------------
MyDataGrid.AllowPaging = "false"
BindGrid()
'-------------------
MyDataGrid.SelectedItemStyle.BackColor=Color.white
MyDataGrid.AlternatingItemStyle.BackColor=Color.white
MyDataGrid.ItemStyle.BackColor=Color.white
MyDataGrid.HeaderStyle.BackColor=Color.white
MyDataGrid.HeaderStyle.ForeColor=Color.red
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Me.EnableViewState = False
Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
MyDataGrid.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()
'-------------------
MyDataGrid.AllowPaging = "true"
BindGrid()
End Sub
</script>
<body>
<form runat="server">
DataGrid Custom Paging Example<BR>
<asp:Button id="button1" onclick="Button1_Click" text="Write To Excle File" runat="server"/>
<BR>
<asp:datagrid id="MyDataGrid"
runat="server"
CellPadding="4"
BackColor="White"
BorderColor="#330033"
BorderWidth="1px"
BorderStyle="None"
Font-Size="9pt"
Font-Names="§ºÊ^"
AllowPaging="true"
pageSize="2"
OnPageIndexChanged="Mydatagrid_PageIndexChanged" >
<PagerStyle Mode="NumericPages"
Font-Bold="true"
BackColor="#F2F2F2"
HorizontalAlign="right">
</PagerStyle>
<SelectedItemStyle BackColor="#FFCC66"></SelectedItemStyle>
<AlternatingItemStyle BackColor="#FFCC99"></AlternatingItemStyle>
<ItemStyle BackColor="White"></ItemStyle>
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" ForeColor="#330033" BorderColor="Black" BackColor="#FF9900"></HeaderStyle>
</asp:datagrid>
</form>
</body>
</html>
jasluen 2004-03-26
  • 打赏
  • 举报
回复
将代码贴出来看看!
wangsaokui 2004-03-26
  • 打赏
  • 举报
回复
use Function WriteXml save data to xml file

private void WriteXmlToFile(DataSet thisDataSet) {
if (thisDataSet == null) { return; }
// Create a file name to write to.
string filename = "myXmlDoc.xml";
// Create the FileStream to write with.
System.IO.FileStream myFileStream = new System.IO.FileStream
(filename, System.IO.FileMode.Create);
// Create an XmlTextWriter with the fileStream.
System.Xml.XmlTextWriter myXmlWriter =
new System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);
// Write to the file with the WriteXml method.
thisDataSet.WriteXml(myXmlWriter);
myXmlWriter.Close();
}

62,040

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧