Small Basic Forum
LDDataBase.EditTable(database, table, dataview) - Printable Version

+- Small Basic Forum (https://litdev.uk/mybb)
+-- Forum: Small Basic (https://litdev.uk/mybb/forumdisplay.php?fid=1)
+--- Forum: Extensions (https://litdev.uk/mybb/forumdisplay.php?fid=3)
+--- Thread: LDDataBase.EditTable(database, table, dataview) (/showthread.php?tid=272)

Pages: 1 2


LDDataBase.EditTable(database, table, dataview) - martmen - 03-22-2025

Hallo zusammen,
Ich würde gerne mit LDDataBase.EditTable(database, table, dataview) gleich zwei Tabellen gleichzeitig bearbeiten. Ist das möglich?


RE: LDDataBase.EditTable(database, table, dataview) - AbsoluteBeginner - 03-22-2025

Yes, that's an interesting question.  Blush


RE: LDDataBase.EditTable(database, table, dataview) - litdev - 03-23-2025

Hi,

"I would like to edit two tables simultaneously using LDDataBase.EditTable(database, table, dataview). Is that possible?"

I guess it depends exactly on what you mean, here is an example of 2 databases being edited at the same time - is this what you mean?

Code:
DBFile1 = Program.Directory+"\DB1.db"
DB1 = LDDataBase.ConnectSQLite(DBFile1)
command = "BEGIN TRANSACTION;"
command = command + "DROP TABLE IF EXISTS Cars;"
command = command + "CREATE TABLE Cars(Id INTEGER PRIMARY KEY, Name TEXT, Cost NUM);"
command = command + "INSERT INTO Cars(Name,Cost)VALUES('Audi','52642');"
command = command + "INSERT INTO Cars(Name,Cost)VALUES('Mercedes','57127');"
command = command + "INSERT INTO Cars(Name,Cost)VALUES('Skoda','9000');"
command = command + "COMMIT;"
LDDataBase.Command(DB1,command)

DBFile2 = Program.Directory+"\DB2.db"
DB2 = LDDataBase.ConnectSQLite(DBFile2)
command = "BEGIN TRANSACTION;"
command = command + "DROP TABLE IF EXISTS People;"
command = command + "CREATE TABLE People(Id INTEGER PRIMARY KEY, Name TEXT, Age NUM);"
command = command + "INSERT INTO People(Name,Age)VALUES('Fred','12');"
command = command + "INSERT INTO People(Name,Age)VALUES('James','33');"
command = command + "INSERT INTO People(Name,Age)VALUES('Mary','21');"
command = command + "COMMIT;"
LDDataBase.Command(DB2,command)

GraphicsWindow.Show()

DV1 = LDControls.AddDataView(240, 350, "")
Shapes.Move(DV1,0,0)
LDDataBase.EditTable(DB1, "Cars", DV1)

DV2 = LDControls.AddDataView(240, 350, "")
Shapes.Move(DV2,250,0)
LDDataBase.EditTable(DB2, "People", DV2)



RE: LDDataBase.EditTable(database, table, dataview) - z-s - 03-23-2025

Arre they working on same time litdev I think it can be done by threading or async only


RE: LDDataBase.EditTable(database, table, dataview) - litdev - 03-23-2025

(03-23-2025, 10:45 AM)z-s Wrote: Arre they working on same time litdev I think it can be done by threading or async only

I guess a user can only edit one at a time so it depends what Martmen is actually trying to do, so if he can provide more details we can see where this leads.


RE: LDDataBase.EditTable(database, table, dataview) - martmen - 03-29-2025

Es ist eine Datenbank mit zwei Tabellen. Beide Tabellen sollen zur selben Zeit auf dem Bildschirm bearbeitet werden. Editiere ich beide Tabellen und speichere über LDDataBase.SaveTable(database,dataview) jede Tabelle, gehen Informationen einer der Tabellen verloren. So ist die Frage gemeint.

Hallo hier ist ein noch nicht fertiges Programm, um Datenbanken in sqlite zu bearbeiten.
55.000 PSSM


RE: LDDataBase.EditTable(database, table, dataview) - z-s - 03-29-2025

Import Code is wrong


RE: LDDataBase.EditTable(database, table, dataview) - martmen - 03-29-2025

Bitte verwenden Sie zum Importieren in "small basic" LSBC640.000


RE: LDDataBase.EditTable(database, table, dataview) - Scout - 03-29-2025

The import code pssm55.000 works, although it is actually too short!  Undecided Huh


RE: LDDataBase.EditTable(database, table, dataview) - litdev - 03-29-2025

Hi Martmen,

This is my test program (BNDW150.000) that has one databse with 2 tables displayed on the GW.  If I make changes to them and Save, then both tables are written to the database.  We can see this with the Load option, or you can actually look at the database file contents with a tool like the one I use https://sqlitebrowser.org.

I hope this helps - the trick is to save and load both tables - I use my test case rather than your file just to keep it simple and focussed on the exact issue you describe.