如何从windows ce设备导出csv文件? [英] How to export csv file from windows ce device?

查看:112
本文介绍了如何从windows ce设备导出csv文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在为windows ce设备做vs2008智能设备项目。我想将数据导出到csv文件,当我执行传输数据时出错。

我附上了我的代码,请给出你的建议



Hi I am doing a vs2008 smart device project for windows ce device. and i want to export the data to a csv file, when i do the transfer data i get an error.
I have attached my code,please give your suggestions

Private Sub BtnAvaStk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnTransData.Click
      
             Using cmd As New SqlCeCommand("SELECT * FROM ItemMaster")
           Using sda As New SqlCeDataAdapter()
               cmd.Connection = con
               sda.SelectCommand = cmd
               Using dt As New DataTable()
                   sda.Fill(dt)

                   'Build the CSV file data as a Comma separated string.
                   Dim csv As String = String.Empty

                   For Each column As DataColumn In dt.Columns
                       'Add the Header row for CSV file.
                       csv += column.ColumnName + ","c
                   Next

                   'Add new line.
                   csv += vbCr & vbLf

                   For Each row As DataRow In dt.Rows
                       For Each column As DataColumn In dt.Columns
                           'Add the Data rows.
                           csv += row(column.ColumnName).ToString().Replace(",", ";") + ","c
                       Next

                       'Add new line.
                       csv += vbCr & vbLf
                   Next


                   Dim folderPath As String = "F:\CSV\DataGridViewExport.csv"
                   File.WriteAllText(folderPath, csv)
                   '' File.OpenWrite(folderPath, csv)
               End Using
           End Using
       End Using
       ''End Using
   End Sub





我的尝试:


在.writealltext中执行错误时显示
并显示为.writealltext不是system.io.file的成员



What I have tried:

while executing error in .writealltext and showing as .writealltext is not a member of system.io.file

推荐答案

***不允许评论此时



您需要使用StreamWriter将数据写出来。
*** Comments are not being allowed at this time

You would need to use StreamWriter to write the data out.


这篇关于如何从windows ce设备导出csv文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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