Junk filed headers
- From: Abdhul Saleem <AbdhulSaleem@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 5 Feb 2007 01:47:00 -0800
Hi,
When I try to open a recordset for a tab delimited csv file, the field names
are not properly displayed. Its showing some junk field names. First row in
the csv file is header row which contains the field name
Public Function GetCSVRecordset(ByVal sLocation As String, ByVal sFileName
As String) As ADODB.Recordset
On Error GoTo ErrorHandler
Dim objFSO As New Scripting.FileSystemObject
Dim objCon As New ADODB.Connection
Dim objRS As New ADODB.Recordset
Dim sFileLoc As String
sFileLoc = sLocation
If Not objFSO.FileExists(sFileLoc & "\" & sFileName) Then
MsgBox sFileLoc & "\" & sFileName & " is missing. Please place the
file " & sFileName & " in " & sLocation
Set objFSO = Nothing
Exit Function
End If
objCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sFileLoc &
";" & _
"Extended Properties=""text;HDR=YES;FMT=Delimited"""
objRS.CursorLocation = adUseClient
objRS.Open "select * from [" & sFileName & "]", objCon, adOpenKeyset,
adLockOptimistic
objRS.ActiveConnection = Nothing
Set GetCSVRecordset = objRS
Set objCon = Nothing
Set objFSO = Nothing
Exit Function
ErrorHandler:
MsgBox "Error Number: " & Err.Number _
& vbCrLf & "Error Description: " & Err.Description _
& vbCrLf & "Error Source: " & Err.Source
Set GetCSVRecordset = Nothing
Set objCon = Nothing
Set objFSO = Nothing
End Function
Please find below the immediate window
?objrs.Fields(0).Name
ÿþS
?objrs.Fields(1).Name
sites#csv.NoName
I am using schema.ini file also, for specifying the Delimiter.
Please tell me what could be the reasons and how to resolve this.
Regards,
M. Abdhul Saleem.
.
- Next by Date: Re: NTWDBLIB.DLL
- Next by thread: Re: NTWDBLIB.DLL
- Index(es):
Relevant Pages
|