svlad

Check-in [831243892a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Now able to connect to database and do some queries and display results.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:831243892a02cd1c25f3b722f7638fd1188ba1b1
User & Date: severak 2012-04-15 15:30:42
Context
2012-04-15
17:24
now basic events are handled check-in: 3d231a001c user: severak tags: trunk
15:30
Now able to connect to database and do some queries and display results. check-in: 831243892a user: severak tags: trunk
13:41
First working version. check-in: 4da807b56b user: severak tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to svlad.lua.

1
2

3
4
5
6







7
8










9
10
11
12
13


14
15
16
17
18
19













20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
--Skeleton SVLADa
require "vcl"


function nasobilka()
  for x=1,9 do
    for y=1,9 do







      tabl:SetCell(x,y,x*y)
    end










  end
end

function sql_dotaz(sender)
  dotaz=table.concat(sql:GetText())


  VCL.ShowMessage(table.concat(sql:GetText(),"\n"))
  if dotaz=="nasobilka" then
    nasobilka()
  end
end














main=VCL.Form("mainWin")
main._={ caption="Svlad", width=500, height=500 }

tabl=VCL.StringGrid(main,"table")
tabl._={ align="alClient", rowCount=99, ColCount=99, AutoEdit=true }

p=VCL.Panel(main,"panel")
p._={ align="alBottom", height=90 }

sql=VCL.Memo(p,"sql")
sql._={ align="alClient",  font={name="Courier"} }

fire=VCL.Button(p,"fire")
fire._={ align="alBottom", caption="PAL!", onclick="sql_dotaz" }

main:ShowModal()


>

|
<
|
>
>
>
>
>
>
>
|

>
>
>
>
>
>
>
>
>
>





>
>
|
<
<



>
>
>
>
>
>
>
>
>
>
>
>
>

|


|











1
2
3
4
5

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
--Skeleton SVLADa
require "vcl"
require "luasql.sqlite3"

function showresult(dotaz)

  res=assert(conn:execute(dotaz))
  if type(res)=="number" then
    VCL.ShowMessage("Zmeneno "..res.." radek.")
  else
    cnames=res:getcolnames()
    tabl.colCount=#cnames+1
    tabl.rowCount=1
    for k,v in pairs(cnames) do
      tabl:SetCell(k,0,v)
    end
    row=res:fetch({})
    while row do
      r=tabl:AddRow()
      tabl:SetCell(0,r,r)
      for k,v in pairs(row) do
        tabl:SetCell(k,r,v)
      end
      row=res:fetch(row)   
    end
    res:close()
  end
end

function sql_dotaz(sender)
  dotaz=table.concat(sql:GetText())
  passed,mesg=pcall(showresult,dotaz)
  if not passed then
    VCL.ShowMessage(mesg)  


  end
end

function listtables()
  showresult("SELECT * FROM sqlite_master")
end

function appEnd()
  conn:close()
  --main:Free()
end

env=luasql.sqlite3()
conn=assert(env:connect("prachy.db3"))


main=VCL.Form("mainWin")
main._={ caption="Svlad", width=500, height=500, onshow="listtables", onclose="appEnd" }

tabl=VCL.StringGrid(main,"table")
tabl._={ align="alClient", rowCount=99, ColCount=99,  AutoEdit=1 }

p=VCL.Panel(main,"panel")
p._={ align="alBottom", height=90 }

sql=VCL.Memo(p,"sql")
sql._={ align="alClient",  font={name="Courier"} }

fire=VCL.Button(p,"fire")
fire._={ align="alBottom", caption="PAL!", onclick="sql_dotaz" }

main:ShowModal()