Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

C#
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


What I have tried:

while executing error in .writealltext and showing as .writealltext is not a member of system.io.file
Posted
Updated 23-Oct-16 18:53pm

1 solution

*** Comments are not being allowed at this time

You would need to use StreamWriter to write the data out.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900