Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: [help] web server and ado connection

  1. #1

    [help] web server and ado connection

    hey everyone im building a web server in delphi 7 with my sql, and after i finish i tried conect my web server with data base, so i use one ado conection but when i run my web server the service stop... some one can give me a tips for use ado connection ...

  2. #2
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,246
    Blog Entries
    2
    The short and somewhat unhelpful answer on tips to use ADO might be don't

    On a more helpful note....

    Which web server components are you using, the Indy ones, or are you writing a CGI app or an ISAPI/Apache module?

    Are you creating one connection to the database and then using it when you process all the requests? Web servers are normally multi-threaded and you can get into a real mess if you're not handling ADO properly.

    So, can you give us some example code? Where you setup the connection, where you use it, that sort of thing?
    :: AthenaOfDelphi :: My Blog :: My Software ::

  3. #3
    so im using iis 7 , i creat new soap with cgi and with soap module... i creat some functions and some arrays ...

    array implemented in interface

    Tcustomer = class(Tremotable)
    private
    FcustUserName : String;
    FcustCode : String;
    FcustName : String;
    FcustInvoiceAddress : Tadress;
    FcustDeliveryAddress : Taddresses;
    FcustNIF : String;
    FcustLogged : String;
    FcustCurrentAcount : String;
    FcustCurrentAcountDocs : Tdocuments;
    FcustPendingOrders : Torders;
    published
    property custUserName : string read FcustUserName write FcustUserName;
    property custCode : string read FcustCode write FcustCode;
    property custName : string read FcustName write FcustName;
    property custInvoiceAddress : Tadress read FcustInvoiceAddress write FcustInvoiceAddress;
    property custDeliveryAddress : Taddresses read FcustDeliveryAddress write FcustDeliveryAddress;
    property custNIF : string read FcustNIF write FcustNIF;
    property custLogged : string read FcustLogged write FcustLogged;
    property custCurrentAcount : string read FcustCurrentAcount write FcustCurrentAcount;
    property custCurrentAcountDocs : Tdocuments read FcustCurrentAcountDocs write FcustCurrentAcountDocs;
    property custPendingOrders : Torders read FcustPendingOrders write FcustPendingOrders;
    end;


    and i try use in webmodule ado querys and ado connection for use in my function on the implementation

    exemple..

    function Twebserver.Login(AUserName, APassword: string) : Tcustomer;
    VAR
    lista_info: Tcustomer;

    begin

    lista_info := tcustomer.create;

    //////////////login success///////////////////////////////////
    // D.qUtilizadores.SQL.Clear;
    webmodule.adologin.SQL.Text:='Select codentidade, nome, nipc, web_passwd from entidades where codentidade='''+AUserName+''' and web_passwd='''+APassword+'''';

    result := lista _info
    exit;


    and in my client when i active the ado connection i got erro 500 in browser wsl and login in client dont work, he dont enter....

  4. #4
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,246
    Blog Entries
    2
    I'm sorry if I ask a dumb question... do you know how to do normal file handling in Delphi? If you're getting a 500 error then your CGI is probably excepting, you're going to need to find out what the exception message is before you go any further.

    Simplest way would be to create a log file, and wrap the connection activation in a try..except block, capture the exception and write the message out to your log file. Let me know if you'd like some example code for this.

    Without knowing what's going on when you try the connect, it's a complete guessing game.
    :: AthenaOfDelphi :: My Blog :: My Software ::

  5. #5
    yeah i know but only apear this error when my ado connection are true and i build the web server if he stay false my webserver run normaly..

  6. #6
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,246
    Blog Entries
    2
    You're going to need to grab the exception that's being raised when you're connecting to the database I'm afraid before I can provide advice on how to fix it.

    Dumb question time again... at design time, can you connect to the database using the ADOConnection object? Have you turned off the 'Login Prompt' (I think the property is LoginPrompt - set it to false if you haven't already).
    :: AthenaOfDelphi :: My Blog :: My Software ::

  7. #7
    yup i can connect at the desing and login are false im using drives odbc may be this is the problem

  8. #8
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,246
    Blog Entries
    2
    So you've got the MySQL ODBC drivers installed... you can connect at design time and login prompt is false.... I'm afraid, it's exception catching time. I've used the MySQL ODBC drivers myself for a while in a CGI (admittedly it was a long time ago, but I know they used to work).

    Code:
    var
      logFile : textFile;
    
    ....
    
      assignFile(logFile,'MyLogFile.log');
      rewrite(logFile);
    
    ....
    
      try
        adoConnection.connect; // I can't remember the exact method as I've not used ADO for a long time
      except
        on e:exception do
        begin
          writeLn(logFile,'Exception class '+e.className+'.  Message:- '+e.message);
        end;
      end;
    
      closeFile(logFile);
    Something like that :-) If it's definitely going bang when you're connecting, then this should give you a fighting chance of figuring out why.
    :: AthenaOfDelphi :: My Blog :: My Software ::

  9. #9
    and you know other method to doing web service easier...

  10. #10
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,246
    Blog Entries
    2
    If you were just going to write a web server that serves pages and files (as opposed to a web service like SOAP), I'd go for the completely self contained option using the Indy HTTP server. Unfortunately, you're not, so the answer is no I don't.

    If it's going bang when you're connecting to the database, then something is either wrong with your connection settings (unlikely as you can connect at design time, unless you're testing it on another machine where the user doesn't have access to the database - MySQL permissions allow for host specific access control, so what works for one user on machine A may not work for that same user on machine B), or you've not done something that the IDE does for you at design time.

    ADO uses COM (I believe), in your code, have you made a call to coInitialize? If not, the COM/ActiveX won't be initialised and all your ADO calls will fail. So if you've got a datamodule, then I would be inclined to use the create and destroy events of the module to call coInitialize and coUninitialize.
    :: AthenaOfDelphi :: My Blog :: My Software ::

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •