AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

SQL Query in object Inspector

Ein Thema von question · begonnen am 8. Feb 2014 · letzter Beitrag vom 10. Feb 2014
Antwort Antwort
question

Registriert seit: 17. Apr 2013
97 Beiträge
 
#1

SQL Query in object Inspector

  Alt 8. Feb 2014, 19:19
Hi,
I am writing a simple query in delphi which is working fine
Code:
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('SELECT bezeichnung FROM artikel where artnr=:ID');
ADOQuery1.Parameters.ParamByName('ID').Value:=2;
ADOQuery1.Open;
but if i write the same code ADOQuery1 in object Inspector and write the following code
Code:
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.Parameters.ParamByName('ID').Value:=2;
ADOQuery1.Open;
i got the following error 'ADOQuery1: Parameter'ID' not found
i dont know why it is not when i write the query in object inspector , i have check database connection and the parameter name as well ,everything is ok
could anybody please help me
Miniaturansicht angehängter Grafiken
screen.png  
  Mit Zitat antworten Zitat
tsteinmaurer

Registriert seit: 8. Sep 2008
Ort: Linz, Österreich
530 Beiträge
 
#2

AW: SQL Query in object Inspector

  Alt 8. Feb 2014, 19:31
Zitat:
ADOQuery1.SQL.Clear;
You are clearing your SQL statement with the above call.
  Mit Zitat antworten Zitat
question

Registriert seit: 17. Apr 2013
97 Beiträge
 
#3

AW: SQL Query in object Inspector

  Alt 9. Feb 2014, 20:55
Thanks for your reply
I have another question, for example i can insert data into two different using one ADOQuery but when i would like to update two table using one ADOQuery then i got an error
"Aplication uses a value of the wrong type for the current operation"
Code:
ADOQuery3.DisableControls;
ADOQuery3.EnableControls;
ADOQuery3.Parameters[0].Value:= Edit1.Text;
ADOQuery3.Parameters[1].Value:=2;
ADOQuery3.Parameters[2].Value:= Edit1.Text;
ADOQuery3.Parameters[3].Value:=1001;
ADOQuery3.ExecSQL;
ADOQuery3.DisableControls;
ADOQuery3.EnableControls;
here is the screen shot for the Query
Miniaturansicht angehängter Grafiken
screen1.png  
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#4

AW: SQL Query in object Inspector

  Alt 9. Feb 2014, 22:20
You should have a closer look to SQL basics and the data controls.

Seems to me, you do not really know what you are doing ...
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat
Medium

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

AW: SQL Query in object Inspector

  Alt 10. Feb 2014, 03: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 03:08 Uhr)
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:55 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz