In addition to what D.R. Hipp said, you are also creating and closing your
db before you get the chance to enter any data, what you really need is to
create a procedure to (1) open db (2) enter data and (3) close db every
time the "execute" button is pressed. Below is a complete working example
of what you want to do. Notice when you use the entry widget you don't
have to worry about using any types of quotes or slashes.
#--------------------- create your DB ---------------------
load c:/tcla/lib/sqlite/tclsqlite3 sqlite3
sqlite3 db c:/test.sql
db eval {
CREATE TABLE t1(a,b,c);
}
set a 0
set b 0
set c 0
#---- fire up this proc when the execute button is hit -----
proc updateDB {a b c} {
sqlite3 db c:/test.sql ;# open db
db eval {insert into t1 values ($a,$b,$c)} ;# enter data
db close ;# close db
}
#----------- create & pack your buttons in tcl --------------
entry .entry1 -width 20 -textvariable a
entry .entry2 -width 20 -textvariable b
entry .entry3 -width 20 -textvariable c
button .button1 -text "execute" -command {updateDB $a $b $c}
pack .entry1 .entry2 .entry3 .button1
#----------------------- the end --------------------------
"D. Richard Hipp"
<[EMAIL PROTECTED]> To:
[email protected]
cc:
08/01/2005 03:30 Subject: Re: [sqlite] using
tcl/tk and sqlite
PM
Please respond to
sqlite-users
See my comments below.
On Mon, 2005-08-01 at 21:06 +0200, Peter Berkel wrote:
> Hallo,
>
> I am not an expert in programming and I try make a frontend
> for sqlite using tcl/tk. See example code below.
>
> I have the following problem. I try to entry data which I want to insert
in a sqlite database. The Values of the textvariables a b and c in the
entry widget are set in the insert statement.
>
> What do I wrong and how can I solve the problem so that I can use the
entry widget to insert, modify and delete dat from a sqlite database.
>
> Thanks for helping me out.
>
> Peter Berkel
>
>
> load tclsqlite3 sqlite3
> sqlite3 db test.db
> db eval {
> CREATE TABLE t1(a,b,c);
> }
>
> set a 0
> set b 0
> set c 0
>
>
> entry .entry1 -width 20 -textvariable a
> entry .entry2 -width 20 -textvariable b
> entry .entry3 -width 20 -textvariable c
>
>
> db eval {insert into t1 values ($a,$b,$c)}
The statement above does the insert, but it does
so immediately, not in response to the button
press. To run this command in response to the
button pressed, do this:
button .button1 -text execute -commmand {
db eval {insert into t1 values($a,$b,$c)}
}
>
> button .button1 -text "execute"
>
> pack .entry1 .entry2 .entry3 .button1
>
> db close
The information transmitted is intended only for the person(s)or entity
to which it is addressed and may contain confidential and/or legally
privileged material. Delivery of this message to any person other than
the intended recipient(s) is not intended in any way to waive privilege
or confidentiality. Any review, retransmission, dissemination or other
use of, or taking of any action in reliance upon, this information by
entities other than the intended recipient is prohibited. If you
receive this in error, please contact the sender and delete the
material from any computer.
For Translation:
http://www.baxter.com/email_disclaimer