Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / DataGrid / October 2004

Tip: Looking for answers? Try searching our database.

CSV file to datagrid, data missing & funny character

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jullietta - 25 Oct 2004 07:57 GMT
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
Jason Brown [MSFT] - 25 Oct 2004 08:31 GMT
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)

Signature

Jason Brown
Microsoft GTSC, IIS

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

> Hi,
>
[quoted text clipped - 38 lines]
>        objConnection.Close()
>    End Sub
Jullietta - 26 Oct 2004 00:15 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.