asp.net 将查询结果保存到本地
一个查询页面 有一个按钮 导出txt
如何在后台cs文件里,将这些文字导出txt文件,保存在本地机子上(即访问客户端的机子)。
GOOGLE上,N多。。
跟下载文件是一样的,只是这个文件是需要生成的
string text = YourText;
Response.Clear();
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AppendHeader("content-disposition", "attachment;filename=\"" + "testdownload.txt\"");
Response.ContentType = "text/plain";
Response.Write(text);
Response.End();
C# code:
using System.IO;
//创建
string filename = "";
StreamWriter SW;
SW = File.CreateText(fileName);
SW.Close();
你就是把导出Excel改一下就好了啊!然后SaveAs
先通过查询在数据库中找到这个文件的名字(或者路径),在用文件下载的方式通过该路径下载到本地即可。
相关问答:
select top 12 * from Product where [id] not in (select top 12 [id] from Product)
这样可以分页,但是我在后面想加个条件
select top 12 * from Product where [id] not in (select top 12 [id] from Prod ......
asp.net ajax中updatepanel里面的控件里面有个button和若干textbox
我点击button验证信息出现,但是就是无法拦截我button后面运行的事件!
验证的代码是JS验证还是.net中的验证控件,或是按钮事件中的后台验证?
......
从数据库中查询一张表的数据
select 部门,姓名 from tb
如何才能生成下面的xml格式文件
<folder state="unchecked" label="全部">
<folder state="unchecked" isBra ......
protected void btnLogin_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Server = (local);user id = sa;pwd = 1;database = Login");
&nb ......
C# code:
SqlConnection conn = CsDB.sqlcon();
SqlDataAdapter da = new SqlDataAdapter("select fwCoding from bjmuma_fwCoding where OrderNumber='" + Order + & ......