• Welcome, Guest. Please login.
 
January 25, 2020, 05:12:26 am

News:

Welcome to the SQLitening support forums!


Recent posts

Pages1 2 3 ... 10
1
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
2
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.
3
You've got Questions? We've got Answers! / Connect using IP address and c...
Last post by cj - January 07, 2020, 08:13:42 pm
This is an old post brought back to life from 2016

Hosts = LocalHost, 192.169.142.164
Hosts = CompuName, 192.169.142.164
 
Use the computer name of the server and not "LocalHost".
This allows connecting by local ip,remote ip and computer name.



Quote from: undefinedOne horrible thought I just had...When I follow slConnect with slOpen how do I know it's actually using the service rather than just working locally? Is it possible for it to connect but not use the connection?

Yes it is possible, but error 18 transmission errors should occur because remote routines are loaded.

slConnect sHost,PortNumber,"E0"
IF slGetErrorNumber THEN
 ? "Don't continue  if connect failed"
 EXIT FUNCTION
END IF
slSetProcessMods "L0" 'if continuing switch back to local routines



? "Hosts=" + GetComputerNameAndIPAddress  'hosts line allowing connecting with all 3-methods. IP,ComputerName,RemoteIP
FUNCTION PBMAIN () AS LONG
 sComputerName$ = PARSE$(GetComputerNameAndIPAddress,1)
 sIpAddress$    = PARSE$(GetComputerNameAndIPAddress,2)
END FUNCTION

FUNCTION GetComputerNameAndIPAddress AS STRING
 LOCAL sComputerName, sIpAddress AS STRING 'return "computername" + "," + "ipaddress"
 LOCAL ip AS LONG, p AS BYTE PTR
 HOST NAME TO sComputerName
 HOST ADDR TO ip
 p = VARPTR(ip)
 sIPAddress = USING$("#_.#_.#_.#", @p, @p[1], @p[2], @p[3])
 FUNCTION = CHR$(sComputerName,",",sIPAddress)
END FUNCTION
4
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
5
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
6
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)?
7
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.
8
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.
9
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
10
You've got Questions? We've got Answers! / Re: slSelBind
Last post by Fim - December 29, 2019, 06:15:06 am
Thanks,
I'll dig into this and see if I understand it.
/Fim W.
Pages1 2 3 ... 10