spyderman4g63
New member
- Joined
- Oct 4, 2006
- Messages
- 3
- Programming Experience
- Beginner
I am importing a .csv fiel into a datagrid. When I import the data, some of the columns are left blank.
data from .csv file:
output from datagrid:
As you can see some of the data in the ItemNumber field has been imported and some of it hasn't. It seems that all of the 000p0*** fields are the only ones left off. I was wondering if I had to set the field type to a string (if that has anything to do with it) and how I would do it.
Here is the code I am using to read the .csv file into datagrid:
data from .csv file:
ItemNumber,UPC,Wharehouse,Description,Department,Sequence,Type,Empty
000P005,000-11034-42005,,DRY VERMOUTH,05,,DSDS,
000P014,000-11034-42005,,DRY VERMOUTH,05,00,REG,
20309,000-12000-00017,,PEPSI 24 PAK,04,,,
722,000-12000-00017,,PEPSI 24 PAK,04,80,DSDS,
output from datagrid:
,000-11034-42005,,DRY VERMOUTH,5,,DSDS,
,000-11034-42005,,DRY VERMOUTH,5,0,REG,
20309,000-12000-00017,,PEPSI 24 PAK,4,,,
722,000-12000-00017,,PEPSI 24 PAK,4,80,DSDS,
As you can see some of the data in the ItemNumber field has been imported and some of it hasn't. It seems that all of the 000p0*** fields are the only ones left off. I was wondering if I had to set the field type to a string (if that has anything to do with it) and how I would do it.
Here is the code I am using to read the .csv file into datagrid:
VB.NET:
Private Sub cmdOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOpen.Click
Dim sConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Duplicates\;Extended Properties=Text;"
Dim objConn As New OleDbConnection(sConnectionString)
objConn.Open()
Dim objCmdSelect As New OleDbCommand("SELECT * FROM test.csv", objConn)
Dim objAdapter1 As New OleDbDataAdapter
objAdapter1.SelectCommand = objCmdSelect
Dim objDataset1 As New DataSet
objAdapter1.Fill(objDataset1, "test")
DataGridView1.DataSource = objDataset1.Tables(0).DefaultView
objConn.Close()
End Sub
Last edited by a moderator: