Hi all,
I've learned lots now, including how to insert data into a table from a
form. I can now click a button on a form which writes data in some
linedits and comboboxes on a form into a table. However, unless I put a
second button on the form and assign insert row, the SQL just overwrites
the first row in the table I'm writing to.
As a very simple example I have a form with a lineditfield whose
datasource is author_table (0) and column is author_name.I launch the
form, the lineeditfield has the first entry in author_table. I put the
following code into the button press for the inserting data into the table.
db=hk_thisform.database()
sourcetable=db.new_table("author_table")
sourcetable.enable()
sourcetable.setmode_insertrow()
(For sake of completeness, the following code does write data to the
table, but just overwrites the first line of the table.)
filtervalue1=hk_thisform.get_pyvisible("author_name_input").value()
sqlstring = "INSERT INTO author_table (author_name) VALUES (" +
filtervalue1 + ");"
db=hk_thisform.database()
query=db.new_actionquery()
query.set_sql(sqlstring)
status=query.execute()
I realise you can click the button at the bottom of the form to insert
new row, but this will be for non-computer people to use, so I need to
make it foolproof.
Is there something I can put in before the script that inserts the data,
to insert a new row before writing the data into the table and
overwriting existing data?
Many thanks,
Rob
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Hk-classes-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hk-classes-discuss