Funny character in first cell of datagrid

J

Jullietta

Hi,

I'm trying to upload a CSV file into a dataset and then trying to
display the dataset using a datagrid.

However, I can only seem to read the first element in the CSV file and
it is being display with a funny 'yp' character.
Here's the code if anyone can spot the problem ... thanx in
advance!!~!


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;"""

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, "CSV.txt")
tempString = objDS.ToString
MyDataGrid.DataSource = objDS.Tables("CSV.txt").DefaultView
MyDataGrid.DataBind()
objConnection.Close()
End Sub
 
C

cbDevelopment

MSDN had an excellent article about using ADO and delimited files. It
can be found at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/dnclinic/html/scripting03092004.asp

The one thing I notice is you are missing the extended property
"FMT=delimited" Refer to the article for specifics. If the link doesn't
work you can search for the title: "Much ADO About Text Files"

Best of luck!

(e-mail address removed) (Jullietta) wrote in
 

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

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top