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