Re: Using parameters with the low level ADO API, trying to avoid the memory leaks.

From: Viatcheslav V. Vassiliev (support_at_oledbdirect.com)
Date: 02/23/05

  • Next message: Rich S.: "Re: Using parameters with the low level ADO API, trying to avoid the memory leaks."
    Date: Wed, 23 Feb 2005 16:16:41 +0300
    
    

    > Satisfied, I changed "WHERE LineID = '1'"
    > to "WHERE LineID = :LineID".

    MS ADO (without ADOExpress or dbGo) passes SQL directly to OLEDB provider.
    You do not say which provider you use, but most of them will not understand
    parameters in for :ParamName. For most providers ? should be used:

    WHERE LineID = ?

    And try to use EmptyParam instead of Null.

    //------------------------------------------
    Regards,
    Vassiliev V. V.
    http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
    ADO.Net
    http://www.oledbdirect.com - The fastest way to access MS SQL Server,
    MS Jet (Access) and Interbase (through OLEDB)

    "Rich" <Arby_001@Yahoo.com> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ:
    news:421bbd1e$1@newsgroups.borland.com...
    >
    > This tale involves using the ADO API. We find a problem, we
    > have a work around, but there is still has a challange to left
    > to be met.
    >
    > We are using Delphi 7 SP1 & MDAC 2.7 SP2 and working with a
    > Paradox table for this experiment.
    >
    > Several others here and I have had problems with memory leaks
    > using TADOConnection and TADOCommand. My app runs 24x7 and
    > I’m getting desperate.
    >
    > I’m now working directly with the Microsoft ADO components as
    > exposed with ADOInt. Types such as CoConnection, CoCommand,
    > and CoRecordSet to bypass some of Delphi's VCL wrapper overhead.
    >
    > I've made progress over the last couple of days getting my feet
    > Wet, but I ran into a problem. I believe it has to do with the
    > way that Visual Basic can call a ComObject vs. Delphi.
    >
    > I started with a simple SQL Update with no parameters. Each
    > time I run the command, the update is reflected properly in
    > the table.
    >
    > Satisfied, I changed "WHERE LineID = '1'"
    > to "WHERE LineID = :LineID".
    >
    > I can populate the parameter as required, either using the
    > Command.Parameters.Refresh() to create and then populate them,
    > or create them individually and use
    > Command.Parameters.Append(objParam) to assign them.
    >
    > When I run the CoCommand’s execute method, the update does not
    > occur. No amount of playing with the parameter, or the data type
    > makes a difference. There isn't any exception generated, just a
    > big fat 0 records affected. The update just does not happen.
    >
    > So I tried the third alternate method of passing a variant array
    > at execute time. That works.
    >
    > Here is the first call:
    >
    > RecordsAffected is an OleVariant.
    > adCmdText is a constant that equals 1. It tells ADO
    > that our CommandText is the literal SQL statement.
    > ParamCol is a Variant, not an OleVariant.
    > objParam is a CoParameter.
    >
    > Fails:
    > ObjCmd.Execute(RecordsAffected,null,adCmdText);
    >
    >
    >
    > Works:
    > ParamCol := VarArrayCreate([0, 0], VarVariant);
    > ParamCol[0] := objParam; {Created earlier}
    >
    > ObjCmd.Execute(RecordsAffected,ParamCol,adCmdText);
    >
    > The VB Call that has worked for me in the past:
    >
    > ObjCmd.Execute RecordsAffected
    >
    > Note the absent values for parameters and option.
    >
    > It seems to me that when I make the original call, it accepts
    > the null as my new parameter list, doing who knows what to my existing
    > parameters.
    >
    > So how does Delphi call an object that has optional parameters
    > without passing data?
    >
    > I would think that this had been covered years ago, but I
    > failed in my search for knowledge.
    >
    > Rich
    >


  • Next message: Rich S.: "Re: Using parameters with the low level ADO API, trying to avoid the memory leaks."

    Relevant Pages

    • Re: ADO call to user defined function
      ... support all the features, which supported by OLEDB. ... OLEDB provider for SQL ... Server was developed some time ago, when SQL Server did not have UDF's. ... is why ADO does not support them as well. ...
      (microsoft.public.data.ado)
    • Re: How to use COLLATE to SORT ADO table by international sorting rules?
      ... ADO does not accept SQL at all and pass command text to OLEDB provider. ... documentation for your DBMS for SQL syntax - it is different for different ...
      (borland.public.delphi.database.ado)
    • Re: Why not use DAO?
      ... You have been refering to DAO vs. ADO when these two things (in the context ... you must have ALREADY used a provider to get to. ... interface for working with JET databases. ...
      (microsoft.public.dotnet.languages.vb)
    • Re: Website Administration Tool not working from published applica
      ... provider, whom most of them can't afford the fancy of dedicated servers - ... SQL Server 2000 instead of SQL Express ... The first mistake was using ... that the Web App Admin Tool shows when it cannot connect to the database. ...
      (microsoft.public.dotnet.framework.aspnet)
    • Re: Why not use DAO?
      ... All reall life programmers i know of use the jet oledb 3.5 or 4.0 provider ... ADO for ACCESS ... The TS asked "Why not used DAO ?" ... interface for working with JET databases. ...
      (microsoft.public.dotnet.languages.vb)