Einzelnen Beitrag anzeigen

Medium

Registriert seit: 23. Jan 2008
3.679 Beiträge
 
Delphi 2007 Enterprise
 
#5

AW: SQL Query in object Inspector

  Alt 10. Feb 2014, 02:02
I whole heartedly agree. There is SO much wrong with your code, that it seems that even if we solve this one for you, you'd run into the next problem pretty much immediately after. But what the hell:
  • TADOQuery.DisableControls/EnableControls dis-/enables all controls, that have that particular query-component set as their data source. Disabling and immediately enabling this does nothing other than a little unnecessary overhead. Especially if you thought it would do things to your TEdit components: It doesn't. Normal TEdits don't have data sources, and thus cannot be disabled for database updates. Also: If you had data sensitive controls, you would not need manual SQL statements for updating values in the DB. (Using data sensitive controls and using manual SQL are mostly mutually exclusive. They're two different techniques for a similar purpose (roughly), and suit different goals more or less well. It depends on what you're doing whether one of those is better than the other in a given case.)
  • You try to give values to four parameters in your query, but you only have declared three: Gender, email and ID. The doubling of ID does not make it a fourth parameter. It thus cannot hold two different values, on top of that.
  • While it usually is possible to pass two SQL statements in one go, you usually have to delimit them by the DBMSs delimiter. In most cases that would be the same as in Pascal: ";", but can differ from DBMS to DBMS.
  • You seem to want to set the gender and email, but you try to put the same text into both fields. (In the wrong way, see above.) But even if you did it right code-wise, it still seems highly illogical.
  • Also, hard coded IDs indicate grave design flaws.
I've seldom seen so many issues in such few lines of code. But please do not see this as an overly mean comment, it just shows that you need to read up on database basics a lot, which is the only thing, that will help you further down the road. Pretty much any tutorial on the topics of SQL and Delphi's data sensitive controls would help, since any of them should cover enough of the basics to make it quite clear what your problems are here.
"When one person suffers from a delusion, it is called insanity. When a million people suffer from a delusion, it is called religion." (Richard Dawkins)

Geändert von Medium (10. Feb 2014 um 02:08 Uhr)
  Mit Zitat antworten Zitat