Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Forest4473
Starting Member
3 Posts |
Posted - 2009-01-14 : 11:42:45
|
| I want to read a string from a text file through the sp_OAMethod method with the following code :declare @String VARCHAR(500)execute @hr = sp_OAMethod @objFileSystem, 'OpenTextFile', @objTextStream OUT, @FilePath, 1, Trueexec sp_OAMethod @objTextStream, 'AtEndOfStream', @blnEndOfFile outwhile @blnEndOfFile=0 begin exec sp_OAMethod @objTextStream, 'ReadLine', @String out print @String exec sp_OAMethod @objTextStream, 'AtEndOfStream', @blnEndOfFile outendThen, 3 loops are done whereas there are only 2 lines in my file :'toto1' and 'toto2'. The first returned string is 'ÿþt' instead of 'toto1'. Then, the 2 following lines are empty.Thanks in advance for your help and your ideas. |
|
|
Forest4473
Starting Member
3 Posts |
Posted - 2009-01-15 : 03:32:54
|
| My problem comes from writting.The 'Writeline' sp_OAMethod adds 'ÿþ' at the beginning of my file.execute @hr = sp_OAMethod @objTextStream, 'Writeline', Null, @String, 2, TrueWho knows why ? |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-01-15 : 03:36:12
|
Have you considered UNICODE in either file or OpenTextFile method? E 12°55'05.63"N 56°04'39.26" |
 |
|
|
Forest4473
Starting Member
3 Posts |
Posted - 2009-01-15 : 03:47:59
|
| I just change the 'writeline' sp_OAMethod method into :execute @hr = sp_OAMethod @objTextStream, 'Writeline', Null, @Stringand it works |
 |
|
|
|
|
|
|
|