• Welcome, Guest. Please login.
 
July 04, 2020, 04:22:37 pm

News:

Welcome to the SQLitening support forums!


What will be the best way to unload the forms in VB6

Started by jonas, October 10, 2008, 04:08:40 pm

Previous topic - Next topic

jonas

I already try disconnect, close and closeset, but nothing seems to works, everytime that I connect to the database (it works beatifull) but when I close the application it send an error message saying that there was an error with the library

AppName: test.exe    AppVer: 1.0.0.0    ModName: ntdll.dll
ModVer: 5.1.2600.5512    Offset: 000113a0

Thanks.

Matt Humphreys


Paul Squires

Does the error happen after running the code in the VB IDE, or after the exe is run from outside the IDE.

Another reason why I don't miss VB.  :D    (sorry about that)

jonas

on_click command button

10    On Error GoTo errlog

20    x = Module1.slConnect("192.168.1.103", "51234", "E1")
If x <> 0 Then MsgBox x
30    x = Module1.slOpen("CMMS.db3", "E1")
If x <> 0 Then MsgBox x
40    x = Module1.slSel("SELECT * FROM users WHERE UserName = '" & "John" & "'", FoundUser, "E1")
If x <> 0 Then MsgBox x
50    If x = 0 Then
60        MsgBox "Yes"
70    Else
80        MsgBox "nop"
90    End If
100   Module1.slCloseSet FoundUser

110   'Module1.slDisconnect
120   Exit Sub
errlog:
130   MsgBox x & " " & Err.Number And Err.Description & Erl

mikedoty

If you haven't saved the project in the folder with the DLL's and are working in
the environment then CHDIR in Form_Load  while working within the environment. 
This should compete with PB programs.

The lockups I had previously were from attempting to create recordsets before others have
completed and disconnecting while still working.  This code prevents that.

This code works so well I'm going to change my PB code to work the same way.



Option Explicit

  Dim gConnectFlag As Long 'global
  Dim gWorking As Long     'global
  Dim gsArray() As String  'recordset into array

Private Sub Command1_Click()

  If gWorking Then MsgBox "Still working": Exit Sub  'don't allow multiple executions
  gWorking = 1
 
  Dim result As Long, row As Long, col As Long, Cols As Long, s As String
  Dim sArray() As String
  Dim MoreRows As Long
  Dim LastRow As Long
 
  's = "192.168.0.101"
  'result = slConnect(s, 0, "E0")
  'If result Then MsgBox "Connect error" + Str$(result): GoTo Exit1
 
  result = slOpen("sample.db3", "C")  'Create database if it doesn't exist
  If result Then MsgBox "Unable to open database": GoTo Exit1
 
  slSetProcessMods "E0"
  gConnectFlag = 1
 
  s = "SELECT ROWID, * FROM PARTS"
  result = slSel(s, 0, "E0")
  If result Then MsgBox "slSel error" + Str$(result): GoTo Exit1

'---------------------------------------------------------- 
  Cols = slGetColumnCount
  If Cols = 0 Then MsgBox "No columns to return": GoTo Exit1

  MoreRows = 5000      'increase for more speed
  ReDim gsArray(Cols, MoreRows)
 
  row = 0
  Do While slGetRow
    row = row + 1
    If row Mod MoreRows = 0 Then
      ReDim Preserve gsArray(Cols, row + MoreRows)
      Me.Caption = row
      DoEvents
    End If
    For col = 1 To Cols
      gsArray(col, row) = slF(col)
    Next
  Loop
  LastRow = row
  slCloseSet (0)
  Me.Caption = LastRow
  ReDim Preserve gsArray(Cols, LastRow) 'shrink to actual size
 
  row = LastRow
  s = ""
  For col = 1 To Cols
      s = s + gsArray(col, row) + "  "
  Next
  MsgBox s
 
Exit1:
gWorking = 0
End Sub

Private Sub Form_Unload(Cancel As Integer)
  If gWorking Then Cancel = 1: Exit Sub    'still busy, don't allow to end
  If gConnectFlag Then slCloseSet (0): slDisconnect: gConnectFlag = 0
End Sub


mikedoty

If slSetProcessMods is called before connecting it doesn't crash compiled, but
it terminates after clicking on command button to execute.  It does connect and disconnect.


If gWorking Then MsgBox "Still working": Exit Sub  'don't allow multiple executions
  gWorking = 1
 
  Dim result As Long, row As Long, col As Long, Cols As Long, s As String
  Dim sArray() As String
  Dim MoreRows As Long
  Dim LastRow As Long
 
  '----------------------------------------------------------------------------------------
  slSetProcessMods "E0"  'must be called before connecting or crashes compiled
  '----------------------------------------------------------------------------------------
'If compiled after connecting the form disappears and the connection is disconnected.
I have a monitor on the server and it connects/disconnects fine.


mikedoty

October 17, 2008, 11:44:49 pm #6 Last Edit: October 18, 2008, 12:44:27 am by Mike D
Isolated the problem down to slConnect
If running local it works compiled or in the environment.
If compiled the form appears, connection is done, disconnect is done and it terminates.

The work-around might be to have a separate DLL that calls all the functions.
It is very strange that it works in the environment, but not compiled.

Wrote a DLL that is called by VB6 and this DLL calls SQLitening.DLL.
It works a couple of times and then GPF.