Being "proper" in a SQL world using TADOQuery


2005-06-07 11:05:18 PM
delphi147
Most of by coding is done against a MS SQL DB. Given a simple example such as accpeting values
for 10 fields from the user to be inserted into a table I'd typically construct my project as follows:
First, create a main for with non DB-aware controls on it for all 10 fields.
Second, create a buisness layer unit if there needs to be some processing done based on values
entered at the time of entry.
Third, create a data module (my data layer) with a TADOQuery on it to be used to do the insert. I
would create a SaveRecord method for this query that would build the SQL statement based on the
values entered on the main from. You can see that this quickly becomes cumbersome because I
need to now send the SaveRecord method 10 parameters in order to build the SQL statement.
I have these tidbits in memory from past experiences and browsing groups:
1) Never use a Table when dealing with MS SQL.
2) Using parameters in a TADOQuery (like :paramname) will give you grief.
3) You should not create the SQL statement (or other DB specific stuff) in the user interface (my main
form)
How can I overcome my concerns? Can anyone give me a better structure?
Thanks,
Rick