Re: Error using ado to read cvs file
- From: "ekkehard.horner" <ekkehard.horner@xxxxxxxx>
- Date: Thu, 13 Sep 2007 09:50:41 +0200
Light schrieb:
Hi All,
I am using the following code to read csv file, but I am getting error if the data in the following column is having the different format.
For example, I have two rows:
1234, 1234
abcd, 1234
Instead of getting abcd, I will get a null string. If the column in the second row is also a number likes 56789, it will be fine. The same error goes for the second column if the data format changed.
So is my set up correct?
------------------------------------------------
Set Conn = Server.CreateObject("ADODB.Connection")
strConn = "Driver={Microsoft Text Driver (*.txt;*.csv)};" & _
"DefaultDir=" & path
'Opens the connection to the data store
Conn.Open strConn
' csv file
strCmd = "SELECT * from [" & filename & "]"
Set RS = Server.CreateObject("ADODB.Recordset")
'Opens the recordset
RS.Open strCmd, Conn,adOpenStatic,adLockReadOnly
oRs.Fields(0).Value = "" if data format changed from the previous row.
--------------------------------------------------
TIA
P.S. If I am in the wrong NG, please point me to the correct one.
The text driver guesses at the format of a .csv file, if he/she/it
doesn't find a schema.ini file containing the specification/definition
in the same directory. So create such a file - c.f.
http://support.microsoft.com/?scid=kb%3Ben-us%3B187670&x=18&y=14
and give CHAR as data type for your columns.
.
- References:
- Error using ado to read cvs file
- From: Light
- Error using ado to read cvs file
- Prev by Date: Error using ado to read cvs file
- Next by Date: RE: Error using ado to read cvs file
- Previous by thread: Error using ado to read cvs file
- Next by thread: RE: Error using ado to read cvs file
- Index(es):
Relevant Pages
|
|