Leading zero

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I have the foll csv fil

01,1211
02,1415
05,1101
10,0011
34,0000
03,1100

I have the following code that parse the text file and put the result in a datagrid but it is removing leading zeros so 01 is returned as 1. Why


Dim strFileName As String = "pos.txt
Dim strFilePath As String = "C:\test\
Dim dsCSV As New DataSe

Tr
Dim f As System.IO.Fil
If f.Exists(strFilePath & strFileName) The
Dim ConStr As String =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
strFilePath & ";Extended Properties=""Text;HDR=No;FMT=Delimited\""

Dim conn As New OleDb.OleDbConnection(ConStr
Dim daCSV As New OleDb.OleDbDataAdapter("Select * from " &
strFileName, ConStr

daCSV.Fill(dsCSV, "TextFile"

' MsgBox(dsCSV.Tables("TextFile").Rows.Count

End I
Catch ex As Exceptio
MessageBox.Show(ex.ToString
End Tr

DataGrid1.DataSource = dsCSV.Tables(0
 
You'll need to add a tablestyle and a column style. You can set the format
of the Column. I believe "#0,#####" should do it.
Chris said:
Hi,
I have the foll csv file

01,12111
02,14155
05,11011
10,00114
34,00001
03,11000

I have the following code that parse the text file and put the result in a
datagrid but it is removing leading zeros so 01 is returned as 1. Why?
 
What if I need to send the dataset to the database? The dataset is already filled with values wihout the zero. Is there another way to parse the text file and keep the zeros. I will have to send this data to the database and I need the leading zeros

Thanks
 
If you need to physically change the values, then this isn't going to do it
for you. What type of back end are you using?
Chris said:
What if I need to send the dataset to the database? The dataset is already
filled with values wihout the zero. Is there another way to parse the text
file and keep the zeros. I will have to send this data to the database and I
need the leading zeros.
 
Hi
I am using sql server 2000. What else can I use to parse the data from the CSV text file and send it ti the database wothout removing the zeros

Thanks
 
DTS, which is probably a much more elegant solution.
Chris said:
Hi,
I am using sql server 2000. What else can I use to parse the data from the
CSV text file and send it ti the database wothout removing the zeros?
 
Back
Top