• Welcome, Guest. Please login.
 
April 01, 2020, 03:49:41 pm

News:

Welcome to the SQLitening support forums!


Recent posts

Pages1 2 3 ... 10
1
In my system, I handle all processing of a Sql database via a special IO module, a module for each table. Everything works as I had imagined. But in a special case I get error code 7. I have done some tests and it seems I do NOT get error if I make all SQL calls directly in a program without going through an io module.
I get the error after 3732 calls with function GU (get unique).

FUNKTION_GU:
'===========
'
GU_SELECT:
    slOpen TRIM$(KOM.DATABAS)
    SET_NUMMER = slGetUnusedSetNumber
    SEL_STRANG = "SELECT * FROM ART WHERE ARTNR= " + $SQ + TRIM$(ART.ARTNR) + $SQ
    SVAR = slSel(SEL_STRANG, SET_NUMMER) ' Ska ge noll
    IF SVAR <>  0 THEN
        KOM.FELTEXT = "SYSTEMFEL i ARTIO GU slSel=" + STR$(SVAR)  <<============
        GOTO SYSTEMFELHANTERING
        EXIT SUB
    END IF

Tips where to look for errors are gratefully received.
/Fim W.



2
You've got Questions? We've got Answers! / slOpen twice problem.
Last post by cj - March 29, 2020, 09:11:05 pm
It seems a handle may not be released if slOpen is called more than once.
Also, error codes do not seem to be returned.

FUNCTION PBMAIN()
 slOpen "trash.db3","C E2"
 slOpen "trash.db3","C E2" 'should be an error?
 slClose
 IF slIsOpen = 0 THEN ? "database is closed"
 KILL "trash.db3"                
 ? ERROR$,,"Status of kill" 'permission denied
END FUNCTION
3
You've got Questions? We've got Answers! / Re: slSelBind
Last post by cj - January 15, 2020, 12:49:51 pm
Fim,

Note: TRIM$ causes problems with lines requiring leading or trailing spaces.
I put it into a macro only for convenience in an above example.
MACRO btt(parm) = slBuildBindDat(TRIM$(parm),"T") 'bind trim text (not good loading files)
MACRO bt(parm)=slBuildBindDat(parm,"T")'bind text

Binding makes loading or saving files or strings into columns work "as is" without the $SQ issues.
Binding strings without "T" should only be used with binary/blob data so it compares correctly.

#INCLUDE "sqlitening.inc" 'fim00.bas
FUNCTION PBMAIN () AS LONG
 LOCAL COL AS LONG, sresult, search AS STRING
 slOpen
 slexe "create table t1(C1 text collate nocase,C2 text collate nocase)"
 slexeBind "insert into t1 values(?,?)",slBuildBindDat("Heidi","T") + slBuildBindDat("Klum","T")
 slexeBind "insert into t1 values(?,?)",slBuildBindDat("Heidi","T") + slBuildBindDat("Mouse","T")
 slexeBind "Insert into t1 values(?,?)",bt("Heidi") + bt("Macro used") 'for convenience
 search = "HEIDi"
 slSelBind "Select c1,c2 From t1 Where c1 = ? Order by c2", slBuildBindDat(search,"T")
 DO WHILE slGetRow:FOR COL=1 TO slGetColumnCount:sresult+=USING$("&&",slf(COL),$TAB):NEXT:sresult+=$CR:LOOP:?sresult
END FUNCTION
4
You've got Questions? We've got Answers! / Re: slSelBind
Last post by Fim - January 15, 2020, 08:50:05 am
Thank you, that looks good.
Right now I have other problems.
Will return.
5
You've got Questions? We've got Answers! / Re: Beep Notification
Last post by cj - January 04, 2020, 05:23:28 pm
Requires Windows 10 Pro

Only receivers computer names and or IP addresses are used.
"mycomputer" could be any computer name on the network.
Sending to 127.0.0.1 sends to yourself.
Could not get to BEEP and moved to General Board.

Windows MSG.EXE command doesn't send slGetError because of a leading "-"!
Added code to handle TRIM$ of message starting with a "-" or "/" or a blank message.
Added sending result of slPut as a NetSendMessage example.

NetSendMessage computers$, sMsg$, TimeOnScreen&

https://sqlitening.planetsquires.com/index.php?topic=9753.0
6
General Board / Message to any computers on lo...
Last post by cj - January 04, 2020, 10:55:09 am
[source]
#INCLUDE "sqlitening.inc"
'Requires Windows 10 Pro

FUNCTION PBMAIN () AS LONG 'NetSend.bas

 LOCAL sUsers,sFile,sData,sMsg AS STRING

 sFile  = "test123.dat"             'must be in FACT or error -9
 sData  = "some data"               'second parameter of slPut

 sUsers = "127.0.0.1"               'receivers of shell(msg.exe)
 slPutFile sFile,sData,"E0"         'slPut using SQLitening
 sMsg   =  sFile + $CR + slGetError 'message for receivers

 NetSendMessage sUsers,sMsg,0       '0=don't timeout on receiver screens

END FUNCTION

SUB NetSendMessage(sComputers AS STRING,BYVAL sMsg AS STRING, SecondsOnScreen AS LONG)
 LOCAL sShell AS STRING
 IF INSTR("-/",LEFT$(TRIM$(sMsg),1)) THEN
  sMsg = WRAP$(sMsg,"[","]") 'TRIM of sMsg started  "-" or "/" or is empty
 END IF

 'Messages are independent of programs
 'They are placed in a queue and only 1 is displayed on receiving computer
 'If Time: (SecondsOnScreen=0) received must click to clear the message off the screen
 'Sending message to all sessions using the "*" may be needed so it automatically insert
 'If first character of message is "/" or "-"  or "" the message wouldn't send, now wrapped within $DQ

 LOCAL x,pid AS LONG
 FOR x = 1 TO PARSECOUNT(sComputers) 'ComputerName, IPAddress, ...
  'put into a string for your testing
  sShell = "msg.exe /server:"+ TRIM$(PARSE$(sComputers,x)) + " * /time:" + FORMAT$(SecondsOnScreen) + " " + sMsg
  'MSGBOX sShell
  pid = SHELL(sShell,0)
 NEXT
END SUB
#IF 0
SEND a message TO a user.

MSG {username | sessionname | sessionid | @filename | *}
    [/SERVER:servername] [/TIME:seconds] [/V] [/W] [message]

  username            Identifies the specified username.
  sessionname         The NAME OF the session.
  sessionid           The ID OF the session.
  @filename           Identifies a file containing a list OF usernames,
                      sessionnames, AND sessionids TO SEND the message to.
  *                   SEND message TO ALL sessions ON specified server.
  /SERVER:servername  SERVER TO contact (DEFAULT IS current).
  /TIME:seconds       Time delay TO wait FOR receiver TO acknowledge msg.
  /V                  DISPLAY information about actions being performed.
  /W                  Wait FOR response FROM USER, useful WITH /V.
  message             Message TO send.  IF NONE specified, prompts FOR it
                      OR reads FROM stdin.
#ENDIF
7
You've got Questions? We've got Answers! / Re: Beep Notification
Last post by Fredrick Ughimi - January 03, 2020, 01:48:12 pm
Hello Cj,

>>sUsers  = "127.0.0.1, mycomputer"

I need a little explanation here. Is 127.0.0.1 IP address of the computer I am notifying? I guess 'mycomputer' stands for the name of my computer (the sending conputer)?
8
You've got Questions? We've got Answers! / Re: Beep Notification
Last post by Fredrick Ughimi - January 02, 2020, 08:29:41 pm
Hello Cj,

This would serve as well.

Thanks for the codes. Would try it out.
9
You've got Questions? We've got Answers! / Re: Beep Notification
Last post by Bern Ertl - December 30, 2019, 05:20:11 pm
SQLiteningServer doesn't have any methods for pushing notifications to connected clients that I recall.

Your best bet is probably to have connected clients read a transaction file on the server periodically to check for saved updates.
10
You've got Questions? We've got Answers! / Re: slSelBind /slExeBind no w...
Last post by cj - December 29, 2019, 07:00:37 pm
Quote from: undefinedThanks,
I'll dig into this and see if I understand it.
/Fim W.
Welcome.
Hope this is easier to follow.
Happy New Year!

MACRO bt(parm) = slBuildBindDat(TRIM$(parm),"T")

'select bind text
searchfor="HEIDI"
slSelBind "Select c1,c2 From t1 Where c1 = ? Order by c2", slBuildBindDat(TRIM$(searchfor),"T")
slSelBind "Select c1,c2 From t1 Where c1 = ? Order by c2", bt(searchfor)

'insert bind text
sColumn1 = "Heidi"
sColumn2 = "Klum"
slexeBind "Insert into t1 values(?,?)", bt(sColumn1) + bt(sColumn2)

'==========================================================================================
'Example with optimized GetRecordSet function

#INCLUDE "sqlitening.inc"
MACRO bt(parm) = slBuildBindDat(TRIM$(parm),"T")

FUNCTION PBMAIN () AS LONG
LOCAL sColumn1,sColumn2,searchfor,sEverything,rs() AS STRING, x AS LONG

slOpen    "junk.db3","C"
slexe    "Drop Table If Exists T1"
slexe    "Create Table If Not Exists T1(C1 text collate nocase,C2 text collate nocase)"

'insert bind text
sColumn1 = "Heidi"
sColumn2 = "Klum"
slexe "begin immediate"
FOR x = 1 TO 10
  slexeBind "Insert into t1 values(?,?)",bt(sColumn1) + bt(sColumn2)
NEXT
slexe "end"

'select bind text
searchfor = "hEidi"
slSelBind "Select c1,c2 From t1 Where c1 = ? Order by c2", bt(searchfor)

Display data using returned function and by traversing the rs() array
sEverything = "Returned string value" + $CR +  GetRecordSet(rs(), $TAB) + $CR + $CR
sEverything+="Loop through rs() array" + $CR

FOR x = LBOUND(rs) TO UBOUND(rs)
  sEverything+= USING$("#  &&",x,rs(x),$CR)
NEXT
? sEverything,,"Optimized GetRecordSet"
END FUNCTION

'==========================================================================================
FUNCTION GetRecordSet (sRecordSet() AS STRING,sColumnDelimiter AS STRING) AS STRING
LOCAL colnum,rownum,columns,highelement AS LONG
columns = slGetColumnCount                          'number of columns to return
DIM sCol(1 TO columns) AS STRING                    'avoid concatenation of current row
highelement = 10000                                'arbitrary top limit of recordset array

REDIM sRecordset(0 TO highelement) AS STRING        'column names will be in element 0
FOR colnum=1 TO columns                            'for
  sCol(colnum) = slGetColumnName(colnum)            ' get column name for the column
NEXT                                                ' next
sRecordset(0) = JOIN$(sCol(),sColumnDelimiter)      'concatenate into sRecordset(0)

DO WHILE slGetRow                                  'read recordset loop
  INCR rownum                                        'actual number of reads rows
  IF rownum > highelement THEN                      'redim recordset array if needed
   highelement = highelement + 10000
   REDIM PRESERVE sRecordset(0 TO highelement)
  END IF
  FOR colnum = 1 TO columns                          'read columns of current row
   sCol(colnum) = slf(colnum)                        'place into current column array
  NEXT
  sRecordset(rownum) = JOIN$(sCol(),sColumnDelimiter)'concatenate columns into current recordset(row)
LOOP
IF rownum = 0 THEN
  ERASE sRecordSet
  EXIT FUNCTION                                      'exit if no rows returned
END IF
REDIM PRESERVE sRecordset(0 TO rownum)              'shrink array to actual size
FUNCTION = JOIN$(sRecordSet(),$CR)                  'optionally return as string
END FUNCTION
Pages1 2 3 ... 10