spyderman4g63
New member
- Joined
- Oct 4, 2006
- Messages
- 3
- Programming Experience
- Beginner
I am new to vb and writing a program in vb.net 2005 in which I convert a fixed width file to csv then read it into a datagridview.
When I convert the data it works fine.
Sample:
converts to:
But when I read this data into the datagridview it looks like this.
Sample:
for some reason any data in the "item number" field that starts with a 0 is skipped and anything in the sequence and department fields the leading zero's are left off.
Here is the code I am using to read the csv file into the datagrid:
Does anyone know why the Item Number (example: 000P014) fields to be written to the data grid and/or how to have the data grid display the leading zeros on the other fields?
* sorry for the formatting. I tryed to use the <pre> tag with no luck.
When I convert the data it works fine.
Sample:
000P014 000-11034-42005 DRY VERMOUTH 05 00 REG
20309 000-12000-00017 PEPSI 24 PAK 04
converts to:
ItemNumber,UPC,Wharehouse,Description,Department,Sequence,Type,Empty
000P014,000-11034-42005,,DRY VERMOUTH,05,00,REG,
20309,000-12000-00017,,PEPSI 24 PAK,04,,,
But when I read this data into the datagridview it looks like this.
Sample:
000-11034-42005 DRY VERMOUTH 5 0 REG
20309 000-12000-00017 PEPSI 24 PAK 4
for some reason any data in the "item number" field that starts with a 0 is skipped and anything in the sequence and department fields the leading zero's are left off.
Here is the code I am using to read the csv file into the datagrid:
VB.NET:
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()
Does anyone know why the Item Number (example: 000P014) fields to be written to the data grid and/or how to have the data grid display the leading zeros on the other fields?
* sorry for the formatting. I tryed to use the <pre> tag with no luck.
Last edited by a moderator: