Results 1 to 7 of 7

Thread: [RESOLVED] [2005] Error with CSV files

Threaded View

  1. #1

    Thread Starter
    Frenzied Member SomethinCool's Avatar
    Join Date
    Jan 2001
    Location
    Malvern, PA
    Posts
    1,407

    Resolved [RESOLVED] [2005] Error with CSV files

    I have a program that runs a WMI query and writes the data to a temp CSV file then imports that data into a datagrid so the user is able to view the data. When I have this data in the temp file like this:

    Code:
    Server Disk Configuration for myServer
    
    Caption, ConfigManagerErrorCode, Description, DeviceID, DriveType, ErrorDescription, Filesystem, MediaType, Name, TotalCapacity, Status, FreeSpace
    It displays in the datagridview perfectly fine.... but when I have this temp CSV file displayed in the grid:

    Code:
    Server Disk Configuration for myServer
    
    Caption, ConfigManagerErrorCode, Description, DeviceID, DriveType, ErrorDescription, Filesystem, MediaType, Name, TotalCapacity, Status, FreeSpace
    
    C:,,Local Fixed Disk,C:,3,,NTFS,12,C:,45,,28
    D:,,Local Fixed Disk,D:,3,,NTFS,12,D:,30,,25
    E:,,CD-ROM Disc,E:,5,,,11,E:0 GB,,0 GB,
    M:,,Network Connection,M:,4,,MVFS,0,M:,78,,49
    X:,,Network Connection,X:,4,,NTFS,0,X:,1641,,230
    Y:,,Network Connection,Y:,4,,NTFS,0,Y:,678,,59
    Z:,,Network Connection,Z:,4,,MVFS,0,Z:,78,,49
    It doesn't display properly in the grid view. It displays like the image below. What could be wrong? I am just loading the CSV file though an OleDb connection like this:

    vb Code:
    1. Dim objConn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & ";Extended Properties=""Text;HDR=No;FMT=Delimited""")
    2.             Dim objDataAdapter As New OleDb.OleDbDataAdapter()
    3.             Dim objDataSet As New DataSet
    4.             Dim objCommand As New OleDb.OleDbCommand("SELECT * FROM tmp_output.csv", objConn)
    5.  
    6.             objConn.Open()
    7.             objDataAdapter.SelectCommand = objCommand
    8.             objDataSet.Clear()
    9.             objDataAdapter.Fill(objDataSet, "CSV")
    10.             DataGridView.DataSource = objDataSet.Tables(0)
    11.  
    12.             For intColumnIndex As Integer = 0 To DataGridView.Columns.Count - 1
    13.                 DataGridView.Columns(intColumnIndex).SortMode = DataGridViewColumnSortMode.NotSortable
    14.             Next
    15.  
    16.             objConn.Close()
    17.  
    18.             tsProgressBar.Value = 95
    19.  
    20.             IO.File.Delete(Application.StartupPath & "\tmp_output.csv")
    21.             tsProgressBar.Value = 100
    22.  
    23.             tsProgressBar.Value = 0
    Attached Images Attached Images  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width