We would like to build a community for Small Basic programmers of any age who like to code. Everyone from total beginner to guru is welcome. Click here to register and share your programming journey!


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
LDDataBase.EditTable(database, table, dataview)
#1
Hallo zusammen,
Ich würde gerne mit LDDataBase.EditTable(database, table, dataview) gleich zwei Tabellen gleichzeitig bearbeiten. Ist das möglich?
[-] The following 1 user Likes martmen's post:
  • AbsoluteBeginner
Reply
#2
Yes, that's an interesting question.  Blush
Reply
#3
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)
Reply
#4
Arre they working on same time litdev I think it can be done by threading or async only
ZS
Reply
#5
(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.
[-] The following 1 user Likes litdev's post:
  • z-s
Reply
#6
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
Reply
#7
Import Code is wrong
ZS
Reply
#8
Bitte verwenden Sie zum Importieren in "small basic" LSBC640.000
Reply
#9
The import code pssm55.000 works, although it is actually too short!  Undecided Huh
Reply
#10
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)