Export Datagrid to CSV
-
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.
-
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.