Forum > Database

fpweb and sqlquery


I am building an HTTP server application with fpweb and want to run a sqlquery to verify that the username exist in db but getting an access violation when i try to run my sqlquery. What am i doing wrong here?

 with SQLQuery1 do -> SQLQuery1 = <TSQLQUERY> = Cannot access memory at address 0x170

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit umain; {$mode objfpc}{$H+} interface uses  SysUtils, Classes, httpdefs, fpHTTP, fpWeb, SQLDB, DB, SQLite3Conn, httproute; type   { TFPWebModule1 }   TFPWebModule1 = class(TFPWebModule)    SQLConnector1: TSQLConnector;    SQLTransaction1: TSQLTransaction;    SQLQuery1: TSQLQuery;    procedure DoStart(ARequest:TRequest; AResponse : TResponse);  private   public   end; var  FPWebModule1: TFPWebModule1; implementation {$R *.lfm} { TFPWebModule1 }  procedure TFPWebModule1.DoStart(ARequest:TRequest; AResponse : TResponse);var user : String;begin  user := ARequest.ContentFields.Values['user'];  if user = EmptyStr then    with AResponse.Contents do    begin      Add('<form action="' + ARequest.URI + '" method="POST"');      Add('<label for="user">User:</label>');      Add('<input type="text" name="user" id="user" />');      Add('<input type="submit" value="Check user" />');      Add('</form>');    end  else    begin      with SQLQuery1 do        begin          Close();          Clear();          SQL.Text:='SELECT username, password FROM user WHERE username='+QuotedStr(user);          SQLConnection.Connected:=True;          SQLTransaction.Active:=True;          SQLQuery1.Active:=True;          Open();        end;      if SQLQuery1.RecordCount = 1 then        AResponse.Content := 'user: ' + user +'!'      else        AResponse.Content := 'Bad login';    end;end;  initialization  RegisterHTTPModule('TFPWebModule1', TFPWebModule1);  HTTPRouter.RegisterRoute('*', @FPWebModule1.DoStart); end.  

I think, that you have not created an instance of the class and are trying to access it.
Look carefully - SQLQuery1 is not even exist

What does TSQLQuery.Clear do?  Aren't you trying to SQLQuery1.SQL.Clear; ?


[0] Message Index

Go to full version