Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Does StreamReader open file readonly?
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 8.0
Divers
Thread ID:
01434675
Message ID:
01434781
Vues:
37
>Hi,
>
>The ADODB obect probably tries to use read/write permissions when opening the file so try FileShare.ReadWrite
>HTH,
>Viv
>

If I understand correctly, your advise is to apply FileShare.ReadWrite in on option for StreamReader:
Dim fs1 As System.IO.FileStream = New System.IO.FileStream(lcfilename, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read)
Dim lcDataText As New System.IO.StreamReader(fs1)
And instead of System.IO.FileShare.Read in dim fs1... above use FileShare.ReadWrite.


No, it did not work.


Below is what I am doing exactly with ADODB. No matter I run this code from VFP, or from VB.NET, RecordSet fails
to open and with the message (attached).
SrcDTW  = "bpdtw.txt"
pcxdir = "\\pcsNAS01\brdpcx\prod\datafile\"

cnnText = CreateObject("ADODB.Connection")
cnnText.mode= 16  && adModeShareDenyNone
cnnText.Open("Provider=Microsoft.Jet.OLEDB.4.0;" +;
       "Data Source=" + pcxdir + [;Extended Properties="text;HDR=NO;FMT=FixedLength"])

rst_DTW  = CreateObject("ADODB.Recordset")
adLockReadOnly = 1
adOpenStatic = 3
adUseClient = 3
rst_DTW.CursorLocation = adUseClient
rst_DTW.Open("select * from " +SrcDTW+ " WHERE GRADE <>' ULTRA' ORDER BY 3,4", cnnText, adOpenStatic, adLockReadOnly)

?rst_DTW.recordcount

rst_DTW.close
cnnText.close
Any idea, what is wrong? I am using shema.ini file to allow ADODB to see the TXT file structure. Is it possible it is somwehow involved?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform