ADO and CSV Upload ( semicolon delimited file)

ADO and CSV Upload ( semicolon delimited file)

Post by Nitin Pati » Sat, 22 Nov 2003 03:10:16



I have written the function to upload the CSV File from asp pages.
I want to extend that upload facility to semicolon delimited file.
I use ADO to upload the data and it reads the input file in ADO Record
set.
When I tried it with semicolon delimited file it doesn't work.
The following Code shows the connection with Semicolun demilimited file

Dim adoConnection As New ADODB.Connection
Dim adoText As New ADODB.Recordset

' Now open an ADO recordset on the file using the Microsoft Text Driver
adoConnection.Open "Provider=MSDASQL; Driver={Microsoft Text Driver
(*.txt; *.csv)}; Format=Delimited(;); MaxScanRows=0; FIL=text; DBQ=" &
strPath & ";"

adoText.Open "select * from " & strFileName, adoConnection,
adOpenStatic, adLockReadOnly, adCmdText

The Above Code Doesnt work with Semicolen Delimited file. The variable
strPath contains the path of the file and strFilename contains the file
name.
can anyone tell me what i am doing wrong

thanks in advance
regards
Nitin

*** Sent via Developersdex http://www.yqcomputer.com/ ***
Don't just participate in USENET...get rewarded for it!
 
 
 

ADO and CSV Upload ( semicolon delimited file)

Post by Paul Cleme » Sun, 23 Nov 2003 00:52:32


I have written the function to upload the CSV File from asp pages.
I want to extend that upload facility to semicolon delimited file.
I use ADO to upload the data and it reads the input file in ADO Record
set.
When I tried it with semicolon delimited file it doesn't work.
The following Code shows the connection with Semicolun demilimited file

Dim adoConnection As New ADODB.Connection
Dim adoText As New ADODB.Recordset

' Now open an ADO recordset on the file using the Microsoft Text Driver
adoConnection.Open "Provider=MSDASQL; Driver={Microsoft Text Driver
(*.txt; *.csv)}; Format=Delimited(;); MaxScanRows=0; FIL=text; DBQ=" &
strPath & ";"

adoText.Open "select * from " & strFileName, adoConnection,
adOpenStatic, adLockReadOnly, adCmdText

The Above Code Doesnt work with Semicolen Delimited file. The variable
strPath contains the path of the file and strFilename contains the file
name.
can anyone tell me what i am doing wrong


A custom delimiter requires a schema.ini file. The contents would look like the following:

[SemiColonDelimited.txt]
ColNameHeader=False
CharacterSet=ANSI
Format=Delimited(;)

http://www.yqcomputer.com/

The alternative is to modify the default setting in the Registry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Text


Paul ~~~ XXXX@XXXXX.COM
Microsoft MVP (Visual Basic)

 
 
 

ADO and CSV Upload ( semicolon delimited file)

Post by Nitin Pati » Sun, 23 Nov 2003 01:37:54

Hi Paul
isnt it Possible to do it on the fly. Because i am using ASP to upload
the Semi Colon delimited file and then save that file on server. Using
ADO Recordset i do want to make the connection with this file. and read
it



*** Sent via Developersdex http://www.yqcomputer.com/ ***
Don't just participate in USENET...get rewarded for it!
 
 
 

ADO and CSV Upload ( semicolon delimited file)

Post by Paul Cleme » Wed, 26 Nov 2003 03:05:19


Hi Paul
isnt it Possible to do it on the fly. Because i am using ASP to upload
the Semi Colon delimited file and then save that file on server. Using
ADO Recordset i do want to make the connection with this file. and read
it

The Format statement, for specifying a custom delimiter, is ignored in the connection string. There
is no other choice than to use the method I mentioned.


Paul ~~~ XXXX@XXXXX.COM
Microsoft MVP (Visual Basic)