Autor Beitrag
Dayhawk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Mi 05.02.03 23:03 
Hi
ich bin nen totaler DB Anfänger und würde gerne wissen was ich falsch mache (SQL):
ausblenden Quelltext
1:
2:
3:
4:
5:
   
   Query1.close;
   Query1.sql.clear;
   Query1.SQL.Add('INSERT INTO ftpdata (IP) VALUES ('+IP1Edit.Text+')');
   Query1.open;


Danke schonmal für eure Antworten ...

Mfg Dayhawk
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Do 06.02.03 00:51 
Dayhawk hat folgendes geschrieben:
VALUES ('+IP1Edit.Text+')');


das + muß auf beiden Seiten raus.

Gruß
Hansa
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Do 06.02.03 00:55 
Oh je, da seh ich noch was : Das wird Probleme geben, nämlich mit den '. Dazu mußt Du Dich aber erst mal selber schlau machen, wegen Schreibweise innerhalb ''
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Do 06.02.03 01:00 
jappadappadu,habe ich sonst nix zu tun :?:

ungefähr so könnte es aussehen:
ausblenden Quelltext
1:
  Query1.SQL.Add('INSERT INTO ftpdata (IP) VALUES '+Edit1.Text);					


Tja, soweit so gut. Is schon wieder spät.

Gruß
Hansa
Dayhawk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Do 06.02.03 01:01 
Geht noch nicht :(
als Meldung kommt: Invalid use of Values...
hm nagut frag ich mal anders wie kann ich einfach einen Datensatz in meine Datenbank einfügen ?

Mfg Dayhawk
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Do 06.02.03 01:14 
hansa hat folgendes geschrieben:

Query1.SQL.Add('INSERT INTO ftpdata (IP) VALUES '+Edit1.Text);


Hinter VALUES muß ein Leerzeichen, VOR das '. Ist das VALUES nicht ein ARRAY (StringList oder so) :?:

jetzt ists noch später *gähn*. Das da ist aber nicht mehr viel.

Gruß
Hansa
Dayhawk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Do 06.02.03 01:20 
hab ja das leerzeichen gemacht geht trotzdem net ..
kann doch net so schwer sein nen einfachen datensatz in ne DB einzufügen ...

trotzdem danke das du dich noch um mich bemüht hast !


Ich brauch nen einfachen Code der EditFelder in eine Datenbank einfügen kann ... Kann mir mal bitte wer nen SourceCode dazu geben ?

THX
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Do 06.02.03 01:24 
Titel: QQ
Dayhawk hat folgendes geschrieben:
Ich brauch nen einfachen Code der EditFelder in eine Datenbank einfügen kann ... Kann mir mal bitte wer nen SourceCode dazu geben ?


Jetzt kommen dann halt die unvermeidlichen Fragen:

Welche DB ?
Welche Komponenten benutzt Du ?
SQL oder nicht ?
usw.
Dayhawk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Do 06.02.03 01:27 
Paradox 7
und TQuery
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Do 06.02.03 01:38 
SQL oder nicht ? Diese Aussage fehlt. Hier eine Vorlage als Anregung:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
   
  WITH LiefModul.LiefDS DO BEGIN
      active := false;
      SelectSQL.Text := 'SELECT * FROM LIEF8 WHERE NR='+Edit1.Text;
      active := true;
      IF IsEmpty THEN BEGIN
        Showmessage ('neuer Datensatz !');
        insert;
        FieldByName ('LIEFSEIT').value := Today;
        FieldByName ('NR').value := StrToInt (Edit1.text);
      END
   END;
Dayhawk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Do 06.02.03 13:39 
Hi
ja per sql .. ich hab jetzt einen anderen Code geschrieben aber irgendwas ist hier immernoch falsch dran:
ausblenden Quelltext
1:
2:
3:
4:
  Query1.Sql.Clear;
  Query1.Sql.Add('Insert into ftpdata values(NULL, "' + IP1Edit.text + '", "' + AdminEdit.Text + '")');
  Query1.ExecSQL;
  Query1.Sql.Clear;


als Fehlermeldung kommt:
EDBEngineError with message 'Invalid Parameter.'.

Kann mir wer sagen was dort flasch dran ist ?
Mfg Dayhawk
bis11
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1247
Erhaltene Danke: 2

Apple Mac OSX 10.11

BeitragVerfasst: Do 06.02.03 13:51 
Probiere es mal so :

ausblenden Quelltext
1:
2:
3:
4:
Query1.Sql.Clear; 
  Query1.Sql.Add('Insert into ftpdata values (NULL, ' + QuotedStr(IP1Edit.text) + ', ' + QuotedStr(AdminEdit.Text) + ')'); 
  Query1.ExecSQL; 
  Query1.Sql.Clear;


Erklärung :

Du darfst in einer SQL-Anweisung kein Doppelanführungszeichen haben. Es darf immer nur ein einfaches Anführungszeichen sein. Das QuotedStr schreibt Dir die einfachen Anführungszeichen in die SQL-Anweisung.