Home
Top.Mail.Ru Yandeks.Metrika
Forum: "Beginners";
Current archive: 2010.12.19;
Download: [xml.tar.bz2];

Down

One button works, the other does not (adding records to the database) Find similar branches


Первокурсница ©   (2010-09-25 17:32) [0]

Good day! =)
I have a little problem that arose probably due to my carelessness. There is a database with tables Town and Meteo - a database about the weather in different cities. In the Town table of the field Kod_Goroda (counter, key) Nazvanie (text), Oblast (text), Chislo_Giteley (numerical). In the Meteo table, the fields Counter (counter, key), Kod_Goroda (numerical), Data (text), Pogoda (text), Temperatura (numerical). 1-to-many relationship across the Kod_Goroda fields of both tables. I need to add records to both of these tables through Delphi using the INSERT operation so that all records in the table (including those just added) are immediately displayed in DBGrid1 and DBGid2. Here are the procedures for the two buttons:
procedure TForm1.BitBtn6Click(Sender: TObject); {Добавление новых записей в БД табл. Town}
begin
ADOQuery1.Active:=false;
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add("INSERT INTO Town");
ADOQuery1.SQL.Add("(Nazvanie, Oblast, Chislo_Giteley)");
ADOQuery1.SQL.Add("VALUES(""+Edit3.Text +"", ""+Edit4.Text+"", "+Edit5.Text+")");
ADOQuery1.ExecSQL;
ADOQuery1.SQL.Text:="SELECT*FROM Town";
ADOQuery1.Open;
end;

procedure TForm1.BitBtn7Click(Sender: TObject); {Добавление новых записей в БД табл. Meteo}
begin
ADOQuery2.Active:=false;
ADOQuery2.Close;
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add("INSERT INTO Meteo");
ADOQuery2.SQL.Add("(Kod_Goroda, Data, Pogoda, Temperatura)");
ADOQuery2.SQL.Add("VALUES("+Edit2.Text+", ""+Edit6.Text+"", ""+Edit7.Text+"", "+Edit8.Text+")");
ADOQuery2.ExecSQL;
ADOQuery2.SQL.Text:="SELECT*FROM Meteo";
ADOQuery2.Open;
end;

The first procedure works fine, everything adds up, everything is displayed as it should. The second does not work at all - nothing is added and nothing is displayed accordingly. Help me please! :(



Плохиш ©   (2010-09-25 18:45) [1]

You need to put a breakpoint in the procedure and go through the steps.



Первокурсница ©   (2010-09-25 19:12) [2]

Everything worked, thanks = *



Anatoly Podgoretsky ©   (2010-09-25 19:22) [3]

> Freshman (25.09.2010 17: 32: 00) [0]

Make a breakpoint here ADOQuery2.Active: = false;



Pages: 1 whole branch

Forum: "Beginners";
Current archive: 2010.12.19;
Download: [xml.tar.bz2];

Top





Memory: 0.55 MB
Time: 0.013 c
2-1285157997
Buy
2010-09-22 16:19
2010.12.19
Tell me how to build a request


15-1283258914
pasha_golub
2010-08-31 16:48
2010.12.19
Kiev, September 13, 2010, Embarcadero workshop


3-1248764936
tomkat
2009-07-28 11:08
2010.12.19
exporting firebird metadata to script


3-1249558805
ford
2009-08-06 15:40
2010.12.19
double quotes in request


15-1283967501
Ega23
2010-09-08 21:38
2010.12.19
Read Lurk about Web 1.0





afrikaans albanian Arabic armenian azerbaijani basque belarusian bulgarian catalan Chinese (Simplified) Chinese (Traditional) croatian Czech danish Dutch English estonian filipino finnish French
galician georgian German greek haitian Creole hebrew Hindi hungarian icelandic Indonesian Irish italian Japanese Korean latvian lithuanian macedonian malay maltese norwegian
persian polish portuguese Romanian russian serbian slovak Slovenian Spanish swahili Swedish ภาษาไทย turkish Ukrainian urdu Tiếng Việt welsh yiddish bengali bosnian
cebuano Esperanto gujarati hausa hmong igbo javanese kannada Khmer lao latin maori marathi mongolian nepali punjabi somali tamil telugu yoruba
zulu
English French German Italian Portuguese Russian Spanish