⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setting the sql property directly.htm

📁 宇宙中最强悍的Delphi资料专辑宇宙中最强悍的Delphi资料专辑
💻 HTM
字号:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<title>Setting the SQL property directly</title>
</head>

<body>

<table border="0" width="100%" style="font-size: 9pt">
  <tr>
    <td width="100%"><strong>直接设置SQL属性(运行期间)<br>
    </strong>&nbsp;&nbsp;&nbsp; (1)调用Close函数。即使在改变SQL属性的时候会自动关闭查询,不过最好在修改SQL语句之前调用Close方法<strong><br>
    </strong>&nbsp;&nbsp;&nbsp; (2)如果原来的SQL语句不再有用,调用Clear方法。<br>
    &nbsp;&nbsp;&nbsp; (3)如果创建新的SQL语句或者向SQL语句中增加一行,可以调用Add方法;如果要修改某行,需要使用使用SQL属性,并且把索引号设置为要修改的行号,给这行赋予新值。比如:<br>
    &nbsp;&nbsp;&nbsp; CustomerQuery.SQL[1] := 'WHERE Company = &quot;Light Shopp&quot;';<br>
    把CustomerQuery的SQL语句的第2行内容修改为Light Shopp<br>
    &nbsp;&nbsp;&nbsp; (4)调用Open或者ExecSQL执行查询<br>
    <br>
    <strong>举例:</strong><br>
    with CustomerQuery do <br>
    begin<br>
    &nbsp;&nbsp;&nbsp; Close; { close the query if it's active }<br>
    &nbsp;&nbsp;&nbsp; with SQL <br>
    &nbsp;&nbsp;&nbsp; do begin<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Clear; { delete the current SQL statement, if 
    any }<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Add('SELECT * FROM Customer'); { add first line 
    of SQL... }<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Add('WHERE Company = Light Diver'); { ... and 
    second line }<br>
    &nbsp;&nbsp;&nbsp; end;<br>
    &nbsp;&nbsp;&nbsp; Open; { activate the query }<br>
    end;<br>
    <br>
    <strong>提示:</strong><br>
    &nbsp;&nbsp;&nbsp; 
    如果带有参数查询,必须在打开或者执行查询之前调用Prepare方法设置这些参数的初始值。显式地调用Prepare方法对于同一个SQL语句被多次重复调用是非常有用的,否则的话这个SQL会自动由TQuery构件调用。<hr
    size="1">
    <p align="center"><a href="mailto:ilovedelphi@163.net">RainBow</a><font color="#ffffff">。</font>策划制作 
    版权所有</td>
  </tr>
</table>

<p> </p>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -