Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ado problem.. 1

Status
Not open for further replies.

jcisco

Programmer
Sep 17, 2002
125
US
Ok true believers, kudos for anyone that can solve this riddle.
Background:
Using the adodb ver 7.0.3300.0 .NET object ref.
Using foxpro database tables in a local directory.
Using this code:

Private Sub adoTest()
'create CNN and RecSet
Dim cnn As New ADODB.Connection()
Dim Rec As New ADODB.Recordset()

'set path, and table name
Dim sTableName As String = "RNM.DBF"
Dim sFoxProPath As String = "c:\dbf\"


cnn.ConnectionString = "Provider=MSDASQL;dsn=update2;datasource= " & sFoxProPath & sTableName


cnn.Open()

Rec.CursorLocation = ADODB.CursorLocationEnum.adUseClient
Rec.CursorType = ADODB.CursorTypeEnum.adOpenKeyset
Rec.LockType = ADODB.LockTypeEnum.adLockReadOnly


Dim sql As String = "select * from " & sTableName
Rec = cnn.Execute(sql)

' Record found
Dim iNoDocuments As Integer = Val(Rec.Fields("Order").Value & "")
Dim sdocname As String = Trim(Rec.Fields("docname").Value & "")
MsgBox(iNoDocuments & " " & sdocname)
Rec.Close()
cnn.Close()

System.Diagnostics.Debug.WriteLine(" After closing: " & cnn.State)
cnn = Nothing
Rec = Nothing

‘forcing GC to occure.. out of ideas for freeing up dbf file
‘still not working though L
System.GC.Collect(2)
end sub

OK now after that completes if i try to copy the dbf file, kill it or do anything to it.. it says that it's being used by another process.. when this is not the case.

Now the only way that i have been able to get this to work is by opening up a new dbf file, then it seems to free up the old one. but this means that i would have to put in a temp dbf file on the target system..

Suggestions?


--------------
:)
 
Does your DSN have under options "Fetch Data in Background" checked? If so, uncheck it. Hope that helps.

JHall
 
you know it did. i unchecked it.. and the problem is still there.

--------------
:)
 
Sadly, this is not an answer...

You didn't mention what OS you are running - I will assume that it is Windows XP.

I have experienced similar problems with XP, where the file explorer locks the file, making it impossible to delete it. The only solution I have found is to log out and log back in.

 
yup windows xp pro.
I am able to unlock that file by opening up say a temp database file with a new ado connection obj. then i can delete/copy or whatever to the old file.. no prob's.. but i think that it's odd that i need to put in a temp database file that does nothing but release other foxpro tables... although as bad as that bug sucks.. it's nothing compaired to that No source code found. that just pops up out of the blue. that thing sucks. time for a service pack ;)


--------------
:)
 
Have you tried using an odbcCommand object and then invoking the method ExecuteNonQuery? That works pretty well for me getting to SBT Data (VFP 5) from .NET

JHall
 
Namespace: System.Data.Odbc
Assembly: System.Data (in System.Data.dll)

for some reason my system.data does not have Odbc namespace. i have imported the system.data.dll but it's not there. i have also updated my MDAC. i have ole though.



--------------
:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top