数据库字段以在C#中使用asp.net显示文本文件 [英] database fields to display text file using asp.net with C#

查看:72
本文介绍了数据库字段以在C#中使用asp.net显示文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在应用程序中遇到了一个问题,现在我想在显示文本文件或文档中显示数据库(表)值,但是我不知道如何在文本文件中显示数据库字段,任何人都可以帮助我吗?

我使用了SQL server2005.

Hi,

I attended a problem in my application ,now I would like to display the database(table) values to the display text file or the document but I dont know how to display the database fields in text file any one can help me?

I used SQL server2005.

推荐答案

使用2个循环,第一个循环遍历数据表中的行,第二个循环遍历每一行中的列.
使用stringbuilder创建一个字符串,其列名称为空格或制表符,每行的列值.

使用蒸汽写入器将文本输出到文件.
Use 2 loops, the first loop traverses the rows in the datatable, the second loop traverses the columns in each row.

Use a stringbuilder to create a string with column name a space or tab and the column value for each row.

Use a steamwriter to output the text to a file.


这篇关于数据库字段以在C#中使用asp.net显示文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆