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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help ! - Memory Leak with ADODB ActiveX DLL

Status
Not open for further replies.

ReportHacker

Programmer
Apr 25, 2000
7
US
Hi,
I am a newbie to VB (be kind) and have written a small VB DLL (v6.0) that is called from LabVIEW v6.1. The DLL connects and query's a large Citadel db ( and stores the 43200 rows and 100 ish column file (*.txt). I want to know if the following VB code is sound (no leaks) so I can focus on the LabVIEW code as the culprit.
Currently each time I run it through continuously it leaks 100-300k bytes. I've tried
just opening once then grabbing different ADO 2.5 recordsets, and opening each time
and grabbing a recordset. I'm using Windows 2000 Pro Service Pack 3, MDAC 2.5.
I don't know if any VB v6.0 service packs will help either - I'm having problems loading
VB ver6.0 service pack 5 as it can't find the installation (environ. path looks sound).


Option Explicit
'
Private dbConn As ADODB.Connection
Private connectionString As String
Private dbRec As ADODB.Recordset
'

Public Function GetCitadelData(ByVal CitadelDataDir As String, ByVal SQL_Text As String, ByVal NumRows As Long, ByVal TempFilename As String, ByVal OpenConnection As Boolean, ByVal CloseConnection As Boolean)
'
On Error GoTo Error_Handler
'
'
connectionString = "Provider=MSDASQL;" + _
"DRIVER={National Instruments Citadel 4 Database};" + _
"DbAppCharMap=@;" + _
"CitadelCharMap=.;" + _
"MaxColumnNameLength=62;" + _
"ConvertSpecialChars=1;" + _
"DaylightSavings=OS;" + _
"UTCBiasMinutes=OS;" + _
"DataDirectory=" + CitadelDataDir
Set dbConn = New ADODB.Connection ' Create connection object
dbConn.connectionString = connectionString
dbConn.Open
'
If (dbConn Is Nothing) Then
Exit Function
End If
'
connectionString = ""
'
Set dbRec = New ADODB.Recordset ' Create recordset object
dbRec.ActiveConnection = dbConn
'
dbRec.LockType = adLockReadOnly
dbRec.Open SQL_Text
dbRec.CacheSize = NumRows
'
If dbRec.BOF And dbRec.EOF Then
MsgBox "No Rows Returned"
Exit Function
End If
'
dbRec.Save TempFilename, adPersistXML
dbRec.MoveFirst
dbRec.CacheSize = 1
dbRec.Close
dbRec.Source = ""
dbRec.ActiveConnection = Nothing
Set dbRec = Nothing
'
'If CloseConnection = True Then
If (dbConn.State = adStateOpen) Then
dbConn.Close
Set dbConn = Nothing
End If
'End If
'
Exit Function
Error_Handler:
If (dbRec.State <> ADODB.adStateClosed) Then dbRec.Close
MsgBox &quot;(&quot; & Err.Number & &quot;): &quot; & Err.Description, vbCritical + vbOKOnly
'
End Function
 
Hi,

I forgot to add to my first e-mail was that the way I am saving the records to file
is through &quot;dbRec.Save TempFilename, adPersistXML&quot; which saves it as XML.
But this necessitates that I read it in LabVIEW through a parser or through the ADODB.stream to which I see much documentationabout - which is one more step I would like to avoid.

I would like to save the records as tab-delimited text/ascii. Should I look at using
the ADODB.stream avenue and use a &quot;WriteText&quot; approach in the VB DLL? What little I have read says that I must be careful to the current position & EOS etc.. If this is the correct route does anyone have example code/ideas that I could incorporate into what I have posted? Thanks a million!
-reporthacker
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top