CSV file to datagrid, data missing & funny character

J

Jullietta

Hi,

I'm trying to import data from a CSV file to a dataset, then trying to
add this to a datagrid.

Problem is the datagrid is only displaying the first element in the
CSV file with a funny 'yp' character in the first cell.

The header is being created from the schema.ini

The totally confused Jules



Dim strConnectionString As String
Dim strPathToTextFile As String

Dim tempString As String

strPathToTextFile = Server.MapPath("")

strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strPathToTextFile & ";" & _
"Extended Properties=""text;HDR=NO;FMT=Delimited"""

Dim objConnection As New
System.Data.OleDb.OleDbConnection(strConnectionString)
Dim objDS As New DataSet

objConnection.Open()
Dim objDA As New OleDbDataAdapter("SELECT * FROM CSV.txt",
objConnection)

objDA.Fill(objDS)

If ((objDS.ToString <> "") And (objDS.Tables(0).Rows.Count >
0)) Then
'MyDataGrid.DataSource = objDS.Tables(0).DefaultView
MyDataGrid.DataSource = objDS
MyDataGrid.DataBind()

End If
objConnection.Close()
End Sub
 
J

Jason Brown [MSFT]

I suspect what you describe as a funny character is a Unicode identifier -
so problems converting from one character set into another, I suspect. You
may need to set your LCID and/or charsets to handle unicode data (if indeed
this is the problem)


--
Jason Brown
Microsoft GTSC, IIS

This posting is provided "AS IS" with no warranties, and confers no
rights.
 
J

Jullietta

Thanx Jason, all I had to do was change a line in the schema file to
handle unicode characters!!

If anyone else has this problem here is the schema.ini file that
solved my problem.


Cheers
Jules


[CSV.txt]
ColNameHeader=False
Format=CSVDelimited
MaxScanRows=0
CharacterSet=UNICODE
Col1=RecordType Char Width 200
Col2=DateAndTime Char Width 200
Col3=AO Char Width 200
Col4=Object Char Width 200
Col5=asd Char Width 200
Col6=dfg Char Width 200
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top