• Welcome, Guest. Please login.
 
July 15, 2019, 07:48:40 pm

News:

Welcome to the SQLitening support forums!


slgetrow question

Started by D. Wilson, October 06, 2008, 04:15:10 pm

Previous topic - Next topic

D. Wilson

I am using the slgetrow function to load all the records in my database. However it returns only 6640 rows. The database as over 11000 rows.

code:

grid1.MaxRows = 0: grid1.MaxCols = 4
grid1.Visible = False
slConnect "192.168.1.108", 51234, "E0"
slOpen "test.db3"
slSel "Select rowid,* from part"
Do While slGetRow = True
    grid1.MaxRows = grid1.MaxRows + 1
    grid1.Row = grid1.MaxRows
    grid1.Col = 1:    grid1.Text = slF(1)
    grid1.Col = 2:    grid1.Text = slF(2)
    grid1.Col = 3:    grid1.Text = slF(3)
    grid1.Col = 4:    grid1.Text = slF(4)
Loop
slDisconnect
grid1.Visible = True

I deleted a block of data in middle of the database. Could this have returned 'false'. I changed the modchar to return errors and no errors were returned.

D. Wilson

I switched to the 'sample.db3' database and it returned 2476 rows.

Fred Meier

October 06, 2008, 04:38:07 pm #2 Last Edit: October 06, 2008, 06:17:59 pm by Fred Meier
Run the following in local mode.  Then run in remote mode.  Should be same result.
   dim llA as Long
   slopen "sample.db3"
   slsel "select rowid,* from parts"
   do while slgetrow
      llA = llA + 1
   loop
   ? format$(llA)

Use a utility such as SQLite Expert at http://www.sqliteexpert.com verify the contants of the database.

mikedoty

I found the file sample3.db3 (not sure where it comes from)
It has 10,000 rows.

mikedoty

October 06, 2008, 05:34:53 pm #4 Last Edit: October 06, 2008, 05:44:05 pm by mikedoty

mikedoty

'The table name mentioned above is "parts" not "part".
'This works using flexcell.
'It  should get the number of columns instead of hard-code it.
'Also note how the grid is expanded only every 10,000 rows.

Option Explicit

Private Sub Form_Load()
Dim row As Long
Dim result As Long
ChDir "\sql6\bin"

Grid1.Rows = 20000rid1.Cols = 5  '1 higher accounting for 0
Grid1.Visible = False

slSetProcessMods "E0"
result = slOpen("sample.db3", "C")
result = slSel("Select rowid,* from parts")

Do While slGetRow = True
  row = row + 1
  If row > Grid1.Rows Then  'allocate another 10,000
    Grid1.Rows = row + 10000
  End If
  With Grid1
    'use slGetColumnCount
    .Cell(row, 1).Text = slF(1)
    .Cell(row, 2).Text = slF(2)
    .Cell(row, 3).Text = slF(3)
    .Cell(row, 4).Text = slF(4)
  End With
Loop
Grid1.Rows = row + 1 'account for row 0
slDisconnect
Grid1.Visible = True

End Sub


D. Wilson

I looked at the databases the sample.db3 has 10000 rows. The database I created has 11062 rows.
I tried the code above in local mode all rows returned. In remote mode 2476 rows returned.

Fred Meier

October 06, 2008, 11:34:08 pm #7 Last Edit: October 06, 2008, 11:36:37 pm by Fred Meier
I will be gone for several weeks.  Please email that database (one with 11062 rows) to me or zip and post it so I can test with it when I return.

mikedoty

October 06, 2008, 11:36:10 pm #8 Last Edit: October 06, 2008, 11:39:53 pm by mikedoty
What does this return?
SELECT COUNT(*) FROM PARTS;

D. Wilson

I rewrote the code to return selected fields (not all of them).. When the program ran the number of rows returned seems to be related to the amount of data requested. By selecting fewer fields more rows are returned. By selecting just two fields all rows in the database are returned.

mikedoty

Do you still have the file so we can see what is happening?
Did you try count?
Also, noticed in your psedo code the wrong table name and no error checking.

D. Wilson

I attached the file from the server. I know my code had no error checking. The sample file has a table called parts and the test file I created has a table call part. I modified my sql statement and retreived data in the end of the file. The count statement returned 10000 rows. By reducing the field count more data row are returned. This problem only happens in remote mode.

mikedoty

I get the same results running remote.  Please try this code.

#COMPILE EXE
#DIM ALL
#INCLUDE "sqlitening.inc"

FUNCTION PBMAIN AS LONG
  LOCAL rows AS DWORD
  LOCAL result  AS LONG
  LOCAL s       AS STRING
  s = "68.13.44.154"
  result = slConnect(s,0, "E0")
  IF result THEN ? "Unable to connect" + STR$(result):EXIT FUNCTION

  s = "sample.db3"
  result = slOpen(s, "C")
  IF result THEN ? "Error opening database" + STR$(result):EXIT FUNCTION

  s = "SELECT ROWID, * FROM PARTS"
  result = slSel(s)
  IF result THEN ? "slSEL error" + STR$(result):EXIT FUNCTION

  DO WHILE slGetRow
    INCR rows
  LOOP
  ?  "rows =" + STR$(rows)
END FUNCTION
       

mikedoty

When you logged in the following message appears in SQLiteningServer.log:
Received wrong length message, first 64=)

D. Wilson