vb 使用StreamWriter书写流写出数据并生成文件
2024-10-21 17:22:40
sql = "Select case when date ='' then '0'else CONVERT(varchar(100), date, 101) end as date,case when ad ='' then '0'else CONVERT(varchar(100), ad, 101) end as ad,event1,type1,code from EventData where ip='" + UserIP + "' order by code,event1" Dim table As DataTable = gData.GetDataTable(sql, SqlConnect) '將所有的查詢結果放入臨時表中,在查詢臨時表內容
Dim count = table.Rows.Count If count = Then
MessageBox.Show("no data.")
Exit Sub
End If Dim sw As StreamWriter = File.CreateText(TextBox1.Text & "\" & "Events.csv") '在桌面創建文件Events.csv Dim c As String = ""
For i As Integer = To count
If i = Then 'header
sw.WriteLine("E.CODE,E.TYPE,E.EVENT,E.AD,E.DONE") '標題
Else 'data
For j As Integer = To '一共5列
If j = Then
c = table.Rows(i - ).Item(j)
Else
c = table.Rows(i - ).Item(j) & "," & c '對字段進行拼接
End If
Next
sw.WriteLine(c)
c = "" '將C清空
End If
Next sw.Flush()
sw.Close() '新建文件將原有的內容覆蓋
最新文章
- 调用SAP函数创建寄售退货订单的时候报错:业务对象 BUS2032 是销售订单,销售凭证类别 H 是退货。
- python 2.7 简单模拟登陆网站
- EmguCV 轮廓匹配
- SSH基础(2)
- oracle自定义job名字,job调度
- WPF 之 WPF应用程序事件
- VmodCAM图像采集 VGA显示
- HDU 5762 Teacher Bo
- EF查询生成的SQL
- struts2标签库使用小结
- c#枚举值增加特性说明
- s:textarea 标签不能改变大小的解决方案
- spring boot 遇到 supported setting property http://xml.org/sax/properties/lexical-handler
- 01-java技术体系基础
- MySQL 笔记整理(4) --深入浅出索引(上)
- #2019-2020-4 《Java 程序设计》第八周总结
- 【BZOJ3379】[Usaco2004 Open]Turning in Homework 交作业
- python 数据类型 之 字典
- 为sharepoint的内部页面添加后台代码
- 让APK 成功在 Windows 运行并可以设置本地文件