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:
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:
Dim objConn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & ";Extended Properties=""Text;HDR=No;FMT=Delimited""")
Dim objDataAdapter As New OleDb.OleDbDataAdapter()
Dim objDataSet As New DataSet
Dim objCommand As New OleDb.OleDbCommand("SELECT * FROM tmp_output.csv", objConn)
objConn.Open()
objDataAdapter.SelectCommand = objCommand
objDataSet.Clear()
objDataAdapter.Fill(objDataSet, "CSV")
DataGridView.DataSource = objDataSet.Tables(0)
For intColumnIndex As Integer = 0 To DataGridView.Columns.Count - 1
Actually....it is correct... it's the Description text that's throwing it off.... it contains a comma.... Local Disk, C: .... when writing out a CSV, the C is COMMA... so if any of your text happens to contain a comma, you need to enclose the text in quotes....
I think I'm stoned. I don't see anything wrong with the grid except a few of the columns don't have headers. Otherwise the data looks lined up to me.
I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it. My war with a browser-redirect trojan
Starting with deviceID, the cols are off.... Device ID is a Number value... the C: that's jsut before the first Device ID is the ,C: from the description....
The filesystem column looks like it has the right values. But hey, the ultimate judge is the thread starter. If he says it's not right, then it ain't right.
Hey SomethinCool, has this been resolved?
I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it. My war with a browser-redirect trojan