当前位置:编程学习 > Delphi >>

Delphi7中ADODataSet如何使用?

如题,希望能有详细的用法和代码解读.Cloud谢了
答案:

ADODataSet.Close;
ADODataSet.CommandText:= "Select   *   from   Test   where   Code=:Code ";
ADODataSet.Parameters.Clear;
ADODataSet.Parameters.ParseSQL(ADODataSet.CommandText,true);  ADODataSet.Parameters.ParamByName( "Code ").Value   := '001 ';
ADODataSet.Open;以上代码中,语句 ADODataSet1.Parameters.ParseSQL(ADODataSet.CommandText, true) 是关键代码。通过 ParseSQL 方法解构 ADODataSet.CommandText 的 SQL 语句,建立 ADODataSet1 新的对象参数,从而使新的查询生效。

    附:Delphi 文档中对 ParseSQL 方法的描述:

    ParseSQL method (TParameters):

    Parses an SQL statement for parameters and TParameter objects.

    Delphi syntax:

    function ParseSQL(SQL: String; DoCreate: Boolean): String;

    Description

    Call ParseSQL to parse an SQL statement for parameters. For each parameter found in the SQL statement, a TParameter object is added to the calling TParameters object using the name of the parameter in the SQL statement.

    SQL contains the SQL statement to parse.

    DoCreate indicates whether to clear all existing parameter definitions before parsing the SQL statement.

    ParseSQL returns a parsed version of the SQL statement specified in the SQL parameter.

    ADOQuery1.Parameters.ParseSQL(ADOQuery1.Text, True);


上一个:delphi 这段源码谢谢纠正!!!
下一个:Delphi 如何创建有效指针列表

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,