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