Forum > Databases
Add code SQL in the class method
(1/1)
carlos_am_2003:
Hello!
I have a class, for example, TCar and I need to save the data of the class TCar to any database.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TCar = classprivatename: string;year : integer;end
How can I add code to save an object TCar in the database?
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TCar = classprivatename: string;year : integer;procedude SQL_InsertOrUpdate;procedude SQL_Delete;end
OR
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TCar = classprivatename: string;year : integer;end;TSQL_Car = classprocedure SQL_InsertOrUpdate(car : TCar);procedude SQL_Delete(car : TCar);
What do you think?
Help me!
Zvoni:
Do you have code using SQL at all? That's not in a class? that works?
Because right now, i don't get it, what the problem is
MarkMLl:
I think he's looking for a way to serialise an instance into a table.
Deserialisation costs extra :-)
MarkMLl
carlos_am_2003:
Hi!
I would just like an opinion on the best way to go about it.
Zvoni:
How about reading the documentation?
https://wiki.freepascal.org/SQLdb_Programming_Reference
I'd start with "How to set up the SQL-Trinity" (Connection-, Transaction-, Query-Objects)
Navigation
[0] Message Index