DB: Konsolen/Normal-Anwendung mit MS Access

Arne Buchwald

Erfahrenes Mitglied
Hallo,

ich scheine irgendwie im Moment auf einem Schlauch zu stehen - vielleicht auch zeitbedingt ... ;)

Ich habe folgenden Code, der in einer Consolen-Anwendung immer den Error 500 erzeugt.
Code:
procedure TWM.WMsignup2Action(Sender: TObject; Request: TWebRequest;
  Response: TWebResponse; var Handled: Boolean);
var last_id: integer;
  nickname, nickname_show, passwort, passwort_confirm, email, email_confirm: string;
  titel, wohnort, beruf, homepage, interessen, geburtstag, picture_url, icq, aim, yahoo, biografie, signatur: string;
  email_admin_allow, email_showable, pm_allow, pm_notify, topic_time: string;
begin
  try
    {nickname := Request.QueryFields.Values['nickname'];
    nickname_show := Request.QueryFields.Values['nickname_show'];
    passwort := Request.QueryFields.Values['passwort'];
    passwort_confirm := Request.QueryFields.Values['passwort_confirm'];
    email := Request.QueryFields.Values['email'];
    email_confirm := Request.QueryFields.Values['email_confirm'];
    titel := Request.QueryFields.Values['titel'];
    wohnort := Request.QueryFields.Values['wohnort'];
    beruf := Request.QueryFields.Values['beruf'];
    homepage := Request.QueryFields.Values['homepage'];
    interessen := Request.QueryFields.Values['interessen'];
    geburtstag := Request.QueryFields.Values['geburtstag'];
    picture_url := Request.QueryFields.Values['picture_url'];
    icq := Request.QueryFields.Values['icq'];
    aim := Request.QueryFields.Values['aim'];
    yahoo := Request.QueryFields.Values['yahoo'];
    biografie := Request.QueryFields.Values['biografie'];
    signatur := Request.QueryFields.Values['signatur'];
    email_admin_allow := Request.QueryFields.Values['email_admin_allow'];
    email_showable := Request.QueryFields.Values['email_showable'];
    pm_allow := Request.QueryFields.Values['pm_allow'];
    pm_notify := Request.QueryFields.Values['pm_notify'];
    topic_time := Request.QueryFields.Values['topic_time'];  }
    nickname := 'nickname';
    nickname_show := 'nickname_show';
    passwort := 'passwort';
    passwort_confirm := 'passwort_confirm';
    email := 'email';
    email_confirm := 'email_confirm';
    titel := 'titel';
    wohnort := 'wohnort';
    beruf := 'beruf';
    homepage := 'homepage';
    interessen := 'interessen';
    geburtstag := 'geburtstag';
    picture_url := 'picture_url';
    icq := 'icq';
    aim := 'aim';
    yahoo := 'yahoo';
    biografie := 'biografie';
    signatur := 'signatur';
    email_admin_allow := 'email_admin_allow';
    email_showable := 'email_showable';
    pm_allow := 'pm_allow';
    pm_notify := 'pm_notify';
    topic_time := '123';

    AdoConnection1.Connected := True;
    with AdoQuery do
    begin
      Active := False;
      SQL.Clear;
      SQL.Add('Select id from member');
      Open;
      Last;
      last_id := ADOQuery.FieldByName('id').AsInteger;
    end;
    inc(last_id);

    ADOQuery.Active := False;
    ADOQuery.SQL.Clear;
    ADOQuery.SQL.Add('INSERT INTO member VALUES (' + IntToStr(last_id) + ', "' + email + '", ' + '0' + ', "' + homepage + '", "' + icq + '", "' + aim + '", "' + yahoo + '", "' + signatur + '", "' + geburtstag + '", "' + titel + '", "' + biografie + '", "' + wohnort + '", "' + interessen + '", "' + beruf + '", "' + passwort + '", ' + '0' + ', "' + nickname + '", "' + nickname_show + ' ", "' + picture_url + '", "' + email_admin_allow + '", "' + email_showable + '", "' + pm_allow + '", "' + pm_notify + '", ' + topic_time + ')');
//    ADOQuery.SQL.Add('INSERT INTO member (id, email, status, homepage, icq, aim, yahoo, signatur, geburtstag, titel, biografie, wohnort, interessen, beruf, passwort, beitraege, nickname, nickname_show, picture_url,' + ' email_admin_allow, email_showable, pm_allow, pm_notify, topic_time)  VALUES (' + IntToStr(last_id) + ', "' + email + '", ' + '0' + ', "' + homepage + '", "' + icq + '", "' + aim + '", "' + yahoo + '", "' + signatur + '", "' + geburtstag + '", "' + titel + '", "' + biografie + '", "' + wohnort + '", "' + interessen + '", "' + beruf + '", "' + passwort + '", ' + '0' + ', "' + nickname + '", "' + nickname_show + ' ", "' + picture_url + '", "' + email_admin_allow + '", "' + email_showable + '", "' + pm_allow + '", "' + pm_notify + '", ' + topic_time + ')');
    ADOQuery.ExecSQL;
  finally
//    AdoQuery.Active := False;
    PP_signup2.HTMLFile := Templatedir + '\signup_success.html';
    Response.Content := PP_signup2.Content;
//    PP_signup2.HTMLDoc.Add('INSERT INTO member VALUES (' + IntToStr(last_id) + ', "' + email + '", ' + '0' + ', "' + homepage + '", "' + icq + '", "' + aim + '", "' + yahoo + '", "' + signatur + '", "' + geburtstag + '", "' + titel + '", "' + biografie + '", "' + wohnort + '", "' + interessen + '", "' + beruf + '", "' + passwort + '", ' + '0' + ', "' + nickname + '", "' + nickname_show + ' ", "' + picture_url + '", "' + email_admin_allow + '", "' + email_showable + '", "' + pm_allow + '", "' + pm_notify + '", ' + topic_time + ')');
//    Response.Content:= PP_signup2.Content;
  end;
end;

Exakt der gleiche Code läuft in einer normalen Anwendung (mit einem TButton auf einer Form) jedoch problemlos. Woran liegt das??
 
öhm. was ist TWM denn für eine klasse?
und wo tritt der fehler denn auf? sofort beim compilieren oder bricht der debugger bei einer bestimmten zeile ab?
 
Hallo wicked,

TWM = TWebModule

Nein, beim Copilieren tritt der Fehler nicht auf, sondern erst beim Aufrufen der Procedure aus dem Programm.
Und zwar beim Ausführen der SQL-Anweisung:
Code:
  ADOQuery.ExecSQL;

Den SQL-String habe ich schon mehrmals auf Fehler untersucht. (kein String/Integer - Fehler)
Das komische ist halt, dass der Fehler nur bei der Konsolen-Anwendung kommt, bei einer "normalen" Anwendung jedoch nicht.
 
Ich habe das ganze jetzt mal ein bisschen vereinfacht. Die vielen "" durch QuotedStr ersetzt, aber das Problem besteht natürlich weiterhin.

Code:
procedure TWM.WMsignup2Action(Sender: TObject; Request: TWebRequest;
  Response: TWebResponse; var Handled: Boolean);
var last_id: integer;
  nickname, nickname_show, passwort, passwort_confirm, email, email_confirm: string;
  titel, wohnort, beruf, homepage, interessen, geburtstag, picture_url, icq, aim, yahoo, biografie, signatur: string;
  email_admin_allow, email_showable, pm_allow, pm_notify, topic_time: string;
begin
  try
    {
    nickname := Request.QueryFields.Values['nickname'];
    nickname_show := Request.QueryFields.Values['nickname_show'];
    passwort := Request.QueryFields.Values['passwort'];
    passwort_confirm := Request.QueryFields.Values['passwort_confirm'];
    email := Request.QueryFields.Values['email'];
    email_confirm := Request.QueryFields.Values['email_confirm'];
    titel := Request.QueryFields.Values['titel'];
    wohnort := Request.QueryFields.Values['wohnort'];
    beruf := Request.QueryFields.Values['beruf'];
    homepage := Request.QueryFields.Values['homepage'];
    interessen := Request.QueryFields.Values['interessen'];
    geburtstag := Request.QueryFields.Values['geburtstag'];
    picture_url := Request.QueryFields.Values['picture_url'];
    icq := Request.QueryFields.Values['icq'];
    aim := Request.QueryFields.Values['aim'];
    yahoo := Request.QueryFields.Values['yahoo'];
    biografie := Request.QueryFields.Values['biografie'];
    signatur := Request.QueryFields.Values['signatur'];
    email_admin_allow := Request.QueryFields.Values['email_admin_allow'];
    email_showable := Request.QueryFields.Values['email_showable'];
    pm_allow := Request.QueryFields.Values['pm_allow'];
    pm_notify := Request.QueryFields.Values['pm_notify'];
    topic_time := Request.QueryFields.Values['topic_time'];
    }

    nickname := 'nickname';
    nickname_show := 'nickname_show';
    passwort := 'passwort';
    passwort_confirm := 'passwort_confirm';
    email := 'email';
    email_confirm := 'email_confirm';
    titel := 'titel';
    wohnort := 'wohnort';
    beruf := 'beruf';
    homepage := 'homepage';
    interessen := 'interessen';
    geburtstag := 'geburtstag';
    picture_url := 'picture_url';
    icq := 'icq';
    aim := 'aim';
    yahoo := 'yahoo';
    biografie := 'biografie';
    signatur := 'signatur';
    email_admin_allow := 'email_admin_allow';
    email_showable := 'email_showable';
    pm_allow := 'pm_allow';
    pm_notify := 'pm_notify';
    topic_time := '123';

    AdoConnection1.Connected := True;
    with AdoQuery do
    begin
      Active := False;
      SQL.Clear;
      SQL.Add('Select id from member');
      Open;
      Last;
      last_id := ADOQuery.FieldByName('id').AsInteger;
    end;
    inc(last_id);

    ADOQuery.Active := False;
    ADOQuery.SQL.Clear;
    ADOQuery.SQL.Add('INSERT INTO member VALUES (' + IntToStr(last_id) + ',' + QuotedStr(email) + ',' + '0' + ',' + QuotedStr(homepage) + ',' + QuotedStr(icq) + ',' + QuotedStr(aim) + ',' + QuotedStr(yahoo) + ',' + QuotedStr(signatur) + ',' + QuotedStr(geburtstag) + ',' + QuotedStr(titel) + ',' + QuotedStr(biografie) + ',' + QuotedStr(wohnort)+ ',' + QuotedStr(interessen) + ',' + QuotedStr(beruf) + ',' + QuotedStr(passwort) + ',' + '0' + ',' + QuotedStr(nickname) + ',' + QuotedStr(nickname_show) + ',' + QuotedStr(picture_url) + ',' + QuotedStr(email_admin_allow) + ',' + QuotedStr(email_showable) + ',' + QuotedStr(pm_allow) + ',' + QuotedStr(pm_notify) + ',' + topic_time + ')');
//    ADOQuery.SQL.Add('INSERT INTO member VALUES (' + IntToStr(last_id) + ', "' + email + '", ' + '0' + ', "' + homepage + '", "' + icq + '", "' + aim + '", "' + yahoo + '", "' + signatur + '", "' + geburtstag + '", "' + titel + '", "' + biografie + '", "' + wohnort + '", "' + interessen + '", "' + beruf + '", "' + passwort + '", ' + '0' + ', "' + nickname + '", "' + nickname_show + ' ", "' + picture_url + '", "' + email_admin_allow + '", "' + email_showable + '", "' + pm_allow + '", "' + pm_notify + '", ' + topic_time + ')');
//    ADOQuery.SQL.Add('INSERT INTO member (id, email, status, homepage, icq, aim, yahoo, signatur, geburtstag, titel, biografie, wohnort, interessen, beruf, passwort, beitraege, nickname, nickname_show, picture_url,' + ' email_admin_allow, email_showable, pm_allow, pm_notify, topic_time)  VALUES (' + IntToStr(last_id) + ', "' + email + '", ' + '0' + ', "' + homepage + '", "' + icq + '", "' + aim + '", "' + yahoo + '", "' + signatur + '", "' + geburtstag + '", "' + titel + '", "' + biografie + '", "' + wohnort + '", "' + interessen + '", "' + beruf + '", "' + passwort + '", ' + '0' + ', "' + nickname + '", "' + nickname_show + ' ", "' + picture_url + '", "' + email_admin_allow + '", "' + email_showable + '", "' + pm_allow + '", "' + pm_notify + '", ' + topic_time + ')');
    ADOQuery.ExecSQL;
    ADOConnection1.Connected:=False;
  finally
    PP_signup2.HTMLFile := Templatedir + '\signup_success.html';
    Response.Content := PP_signup2.Content;
//    PP_signup2.HTMLDoc.Add('INSERT INTO member VALUES (' + IntToStr(last_id) + ', "' + email + '", ' + '0' + ', "' + homepage + '", "' + icq + '", "' + aim + '", "' + yahoo + '", "' + signatur + '", "' + geburtstag + '", "' + titel + '", "' + biografie + '", "' + wohnort + '", "' + interessen + '", "' + beruf + '", "' + passwort + '", ' + '0' + ', "' + nickname + '", "' + nickname_show + ' ", "' + picture_url + '", "' + email_admin_allow + '", "' + email_showable + '", "' + pm_allow + '", "' + pm_notify + '", ' + topic_time + ')');
//    Response.Content:= PP_signup2.Content;
  end;
end;

[edit]
ICh habe die .exe-Datei eben mal auf meinen Webspace hochgeladen und dort funktionierte das Einfügen in die DB ohne Probleme ... Fehlen bei mir auf dem Rechner evtl. irgendwelche Zugriffsrechte??
[/edit]
Ach, jetzt habe ich's. Murx Win2000-Rechtevergabe!!
 
Zuletzt bearbeitet:

Neue Beiträge

Zurück