📄 c++ builder 程序设计实用教程 - 7_4 sql在数据库中的使用 - 张晋 - 17xie.htm
字号:
Mark'<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN
style="mso-spacerun: yes"> </SPAN>OnClick =
Button10Click<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN style="mso-spacerun: yes">
</SPAN>end<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN style="mso-spacerun: yes">
</SPAN>object Timer1: TTimer<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN
style="mso-spacerun: yes"> </SPAN>OnTimer =
Timer1Timer<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN
style="mso-spacerun: yes"> </SPAN>Left =
192<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN
style="mso-spacerun: yes"> </SPAN>Top =
144<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN style="mso-spacerun: yes">
</SPAN>end<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN style="mso-spacerun: yes">
</SPAN>object DataSource1: TDataSource<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN
style="mso-spacerun: yes"> </SPAN>AutoEdit =
False<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN
style="mso-spacerun: yes"> </SPAN>DataSet =
Query1<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN
style="mso-spacerun: yes"> </SPAN>Left =
136<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN
style="mso-spacerun: yes"> </SPAN>Top =
144<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN style="mso-spacerun: yes">
</SPAN>end<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN style="mso-spacerun: yes">
</SPAN>object Query1: TQuery<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN
style="mso-spacerun: yes"> </SPAN>Active =
True<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN
style="mso-spacerun: yes"> </SPAN>BeforeClose =
Query1BeforeClose<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN
style="mso-spacerun: yes"> </SPAN>DatabaseName =
'BCDEMOS'<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN
style="mso-spacerun: yes"> </SPAN>RequestLive =
True<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN
style="mso-spacerun: yes"> </SPAN>SQL.Strings = ('select
custno,company <o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN
style="mso-spacerun: yes"> </SPAN>from
customer.db')<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN
style="mso-spacerun: yes"> </SPAN>Left =
80<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN
style="mso-spacerun: yes"> </SPAN>Top =
144<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'"><SPAN style="mso-spacerun: yes">
</SPAN>end<o:p></o:p></SPAN></SPAN></P>
<P class=a1><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: 'Times New Roman'">end<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormalIndent><SPAN style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在控件的属性设置过程中,一定要注意以下几个控件的属性设置:</SPAN></SPAN></P>
<P class=MsoNormalIndent
style="MARGIN-LEFT: 42.5pt; TEXT-INDENT: -21.25pt; mso-list: l2 level1 lfo1; tab-stops: list 21.25pt"><SPAN
style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN
style="mso-list: Ignore">n<SPAN
style="FONT: 7pt 'Times New Roman'">
</SPAN></SPAN></SPAN><SPAN lang=EN-US>Timer</SPAN></SPAN><SPAN
style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">控件的</SPAN><SPAN
lang=EN-US>Enable </SPAN></SPAN><SPAN style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">属性设置为</SPAN><SPAN
lang=EN-US>True</SPAN></SPAN><SPAN style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,同时</SPAN><SPAN
lang=EN-US>Interval</SPAN></SPAN><SPAN style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">属性设置为</SPAN><SPAN
lang=EN-US>100</SPAN></SPAN><SPAN style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,即每隔</SPAN><SPAN
lang=EN-US>100</SPAN></SPAN><SPAN style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">微秒程序就会激活一个计时器事件;</SPAN></SPAN></P>
<P class=MsoNormalIndent
style="MARGIN-LEFT: 42.5pt; TEXT-INDENT: -21.25pt; mso-list: l2 level1 lfo1; tab-stops: list 21.25pt"><SPAN
style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN
style="mso-list: Ignore">n<SPAN
style="FONT: 7pt 'Times New Roman'">
</SPAN></SPAN></SPAN><SPAN lang=EN-US>DataSource</SPAN></SPAN><SPAN
style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">控件的</SPAN><SPAN
lang=EN-US>DataSet</SPAN></SPAN><SPAN style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">属性设置为</SPAN><SPAN
lang=EN-US>Query1</SPAN></SPAN><SPAN style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,即将</SPAN><SPAN
lang=EN-US>DataSource</SPAN></SPAN><SPAN
style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">控件与</SPAN><SPAN
lang=EN-US>Query</SPAN></SPAN><SPAN style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">相关联;</SPAN></SPAN></P>
<P class=MsoNormalIndent
style="MARGIN-LEFT: 42.5pt; TEXT-INDENT: -21.25pt; mso-list: l2 level1 lfo1; tab-stops: list 21.25pt"><SPAN
style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN
style="mso-list: Ignore">n<SPAN
style="FONT: 7pt 'Times New Roman'">
</SPAN></SPAN></SPAN><SPAN lang=EN-US>DBGrid</SPAN></SPAN><SPAN
style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">控件的</SPAN><SPAN
lang=EN-US>DataSource </SPAN></SPAN><SPAN
style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">属性设置为</SPAN><SPAN
lang=EN-US>DataSource1</SPAN></SPAN><SPAN
style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,即指明了数据显示的来源;</SPAN></SPAN></P>
<P class=MsoNormalIndent
style="MARGIN-LEFT: 42.5pt; TEXT-INDENT: -21.25pt; mso-list: l2 level1 lfo1; tab-stops: list 21.25pt"><SPAN
style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US
style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN
style="mso-list: Ignore">n<SPAN
style="FONT: 7pt 'Times New Roman'">
</SPAN></SPAN></SPAN><SPAN lang=EN-US>Query</SPAN></SPAN><SPAN
style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">控件的</SPAN><SPAN
lang=EN-US>DatabaseName</SPAN></SPAN><SPAN
style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">属性设置为</SPAN><SPAN
lang=EN-US> 'DBDEMOS'</SPAN></SPAN><SPAN
style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,</SPAN><SPAN
lang=EN-US>SQL</SPAN></SPAN><SPAN style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">属性输入框中输入字符串</SPAN><SPAN
lang=EN-US>"select custno,company from customer.db"</SPAN></SPAN><SPAN
style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,同时</SPAN><SPAN
lang=EN-US>Active</SPAN></SPAN><SPAN style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">属性设置为</SPAN><SPAN
lang=EN-US>True</SPAN></SPAN><SPAN style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,即控件处于活动的状态。</SPAN></SPAN></P>
<P class=MsoNormalIndent><SPAN style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">设置属性后的控件如图</SPAN><SPAN
lang=EN-US>7-18</SPAN></SPAN><SPAN style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">所示。</SPAN></SPAN></P>
<P class=a><SPAN style="mso-bookmark: _Toc392384325"><SPAN lang=EN-US><IMG
height=201
src="C++ Builder 程序设计实用教程 - 7_4 SQL在数据库中的使用 - 张晋 - 17xie.files/cbb44e7401.jpg"
width=281 v:shapes="_x0000_i1025"></SPAN></SPAN></P>
<P class=MsoCaption><SPAN style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">图</SPAN><SPAN
lang=EN-US>7-18<SPAN style="mso-spacerun: yes"> </SPAN></SPAN></SPAN><SPAN
style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">设置属性后的窗体和控件</SPAN></SPAN></P>
<H4><SPAN style="mso-bookmark: _Toc392384325"><SPAN
lang=EN-US>2</SPAN></SPAN><SPAN style="mso-bookmark: _Toc392384325"><SPAN
style="FONT-FAMILY: 楷体_GB2312; mso-ascii-font-family: 'Times New Roman'">.响应</SPAN><SPAN
lang=EN-US>SQL</SPAN></SPAN><SPAN style="mso-bookmark: _Toc392384325"><SPAN
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -