Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Export Datagrid to CSV

Export Datagrid to CSV

Scheduled Pinned Locked Moved Visual Basic
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    japel
    wrote on last edited by
    #1

    Hi All The attached code fills a DataGrid for me from a CSV file. My App manipulates the data and represents it to the use. I then want to export to csv. How is this done??? Private Sub FullImport(ByVal CommString As String, ByVal AnotherCommString As String) Try 'Dim fi As New FileInfo(OpenFileDialog1.FileName) Dim fi As New FileInfo(myFileName) Dim sConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Text;Data Source=" & fi.DirectoryName Dim objConn As New OleDbConnection(sConnectionString) objConn.Open() Dim objCmdSelect As New OleDbCommand(CommString & "[" & fi.Name & "]" & AnotherCommString, objConn) Dim objAdapter1 As New OleDbDataAdapter objAdapter1.SelectCommand = objCmdSelect objAdapter1.Fill(objDataset1, "Import") DataGrid1.DataSource = objDataset1.Tables(0).DefaultView objConn.Close() Catch ex As Exception MessageBox.Show(ex.ToString) End Try End Sub When people make you see red, be thankful your not colour blind.

    C 1 Reply Last reply
    0
    • J japel

      Hi All The attached code fills a DataGrid for me from a CSV file. My App manipulates the data and represents it to the use. I then want to export to csv. How is this done??? Private Sub FullImport(ByVal CommString As String, ByVal AnotherCommString As String) Try 'Dim fi As New FileInfo(OpenFileDialog1.FileName) Dim fi As New FileInfo(myFileName) Dim sConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Text;Data Source=" & fi.DirectoryName Dim objConn As New OleDbConnection(sConnectionString) objConn.Open() Dim objCmdSelect As New OleDbCommand(CommString & "[" & fi.Name & "]" & AnotherCommString, objConn) Dim objAdapter1 As New OleDbDataAdapter objAdapter1.SelectCommand = objCmdSelect objAdapter1.Fill(objDataset1, "Import") DataGrid1.DataSource = objDataset1.Tables(0).DefaultView objConn.Close() Catch ex As Exception MessageBox.Show(ex.ToString) End Try End Sub When people make you see red, be thankful your not colour blind.

      C Offline
      C Offline
      crash893
      wrote on last edited by
      #2

      Wow i was getting ready to post the exact same question Hope some one answers

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups