在线现看午夜福利片|女人16久久免费视频|鲁丝片一区鲁丝片二区鲁丝|一区二区三区欧美在线

  1. 
    
    <b id="glvx9"></b>
        1. <blockquote id="glvx9"><meter id="glvx9"></meter></blockquote>
            首頁 考試吧論壇 Exam8視線 考試商城 網(wǎng)絡(luò)課程 模擬考試 考友錄 實(shí)用文檔 求職招聘 論文下載
            2011中考 | 2011高考 | 2012考研 | 考研培訓(xùn) | 在職研 | 自學(xué)考試 | 成人高考 | 法律碩士 | MBA考試
            MPA考試 | 中科院
            四六級(jí) | 職稱英語 | 商務(wù)英語 | 公共英語 | 托福 | 雅思 | 專四專八 | 口譯筆譯 | 博思 | GRE GMAT
            新概念英語 | 成人英語三級(jí) | 申碩英語 | 攻碩英語 | 職稱日語 | 日語學(xué)習(xí) | 法語 | 德語 | 韓語
            計(jì)算機(jī)等級(jí)考試 | 軟件水平考試 | 職稱計(jì)算機(jī) | 微軟認(rèn)證 | 思科認(rèn)證 | Oracle認(rèn)證 | Linux認(rèn)證
            華為認(rèn)證 | Java認(rèn)證
            公務(wù)員 | 報(bào)關(guān)員 | 銀行從業(yè)資格 | 證券從業(yè)資格 | 期貨從業(yè)資格 | 司法考試 | 法律顧問 | 導(dǎo)游資格
            報(bào)檢員 | 教師資格 | 社會(huì)工作者 | 外銷員 | 國際商務(wù)師 | 跟單員 | 單證員 | 物流師 | 價(jià)格鑒證師
            人力資源 | 管理咨詢師考試 | 秘書資格 | 心理咨詢師考試 | 出版專業(yè)資格 | 廣告師職業(yè)水平
            駕駛員 | 網(wǎng)絡(luò)編輯
            衛(wèi)生資格 | 執(zhí)業(yè)醫(yī)師 | 執(zhí)業(yè)藥師 | 執(zhí)業(yè)護(hù)士
            會(huì)計(jì)從業(yè)資格考試會(huì)計(jì)證) | 經(jīng)濟(jì)師 | 會(huì)計(jì)職稱 | 注冊會(huì)計(jì)師 | 審計(jì)師 | 注冊稅務(wù)師
            注冊資產(chǎn)評(píng)估師 | 高級(jí)會(huì)計(jì)師 | ACCA | 統(tǒng)計(jì)師 | 精算師 | 理財(cái)規(guī)劃師 | 國際內(nèi)審師
            一級(jí)建造師 | 二級(jí)建造師 | 造價(jià)工程師 | 造價(jià)員 | 咨詢工程師 | 監(jiān)理工程師 | 安全工程師
            質(zhì)量工程師 | 物業(yè)管理師 | 招標(biāo)師 | 結(jié)構(gòu)工程師 | 建筑師 | 房地產(chǎn)估價(jià)師 | 土地估價(jià)師 | 巖土師
            設(shè)備監(jiān)理師 | 房地產(chǎn)經(jīng)紀(jì)人 | 投資項(xiàng)目管理師 | 土地登記代理人 | 環(huán)境影響評(píng)價(jià)師 | 環(huán)保工程師
            城市規(guī)劃師 | 公路監(jiān)理師 | 公路造價(jià)師 | 安全評(píng)價(jià)師 | 電氣工程師 | 注冊測繪師 | 注冊計(jì)量師
            繽紛校園 | 實(shí)用文檔 | 英語學(xué)習(xí) | 作文大全 | 求職招聘 | 論文下載 | 訪談 | 游戲

            2011計(jì)算機(jī)等考二級(jí)Delphi輔導(dǎo)講義:SQL編程

            本章主要介紹用Delphi開發(fā)簡單的數(shù)據(jù)庫應(yīng)用程序的一般方法和步驟,首先讓讀者對(duì)Delphi強(qiáng)勁的數(shù)據(jù)庫應(yīng)用開發(fā)工具有一個(gè)直觀的印象,然后在此基礎(chǔ)上進(jìn)行復(fù)雜的數(shù)據(jù)庫應(yīng)用程序的設(shè)計(jì)。

              17.5.2 設(shè)計(jì)一個(gè)數(shù)據(jù)庫查詢器

              例17.2:在數(shù)據(jù)庫查詢器中,用戶可以選擇要查詢的數(shù)據(jù)庫,查詢數(shù)據(jù)庫中的那一個(gè)表、根據(jù)數(shù)據(jù)庫表中那一個(gè)字段進(jìn)行查詢,并且可以方便地指定查詢條件,指定查詢條件主要包括指定邏輯運(yùn)算符(=、>、<、<=、>=、like、in、NOT like、NOT in)和字段值。

              例子全部的程序清單如下:

              unit main;

              interface

              uses

              SysUtils, Windows, Messages, Classes, Graphics, Controls,

              Forms, Dialogs, StdCtrls, DB, DBTables, Buttons, ComCtrls, Tabnotbk;

              type

              TQueryForm = class(TForm)

              BitBtn1: TBitBtn;

              DataSource1: TDataSource;

              Table1: TTable;

              GroupBox1: TGroupBox;

              CheckBox1: TCheckBox;

              CheckBox2: TCheckBox;

              PageControl1: TPageControl;

              TabSheet1: TTabSheet;

              Label5: TLabel;

              Label1: TLabel;

              Label2: TLabel;

              Label3: TLabel;

              Label4: TLabel;

              ListBox1: TListBox;

              ListBox2: TListBox;

              ListBox3: TListBox;

              Edit1: TEdit;

              ComboBox1: TComboBox;

              BitBtn2: TBitBtn;

              TabSheet2: TTabSheet;

              Memo1: TMemo;

              procedure FormCreate(Sender: TObject);

              procedure ListBox1Click(Sender: TObject);

              procedure ListBox2Click(Sender: TObject);

              procedure BitBtn2Click(Sender: TObject);

              end;

              var

              QueryForm: TQueryForm;

              implementation

              {$R *.DFM}

              uses RSLTFORM;

              procedure TQueryForm.FormCreate(Sender: TObject);

              begin

              Screen.Cursor := crHourglass;

              { Populate the alias list }

              with ListBox1 do

              begin

              Items.Clear;

              Session.GetAliasNames(Items);

              end;

              { Make sure there are aliases defined }

              Screen.Cursor := crDefault;

              if ListBox1.Items.Count < 1 then

              MessageDlg( 'There are no database aliases currently defined. You

              need at least one alias to use this demonstration.',

              mtError, [mbOK], 0 );

              { Default the drop-down list to the first value in the list }

              ComboBox1.ItemIndex := 0;

              end;

              procedure TQueryForm.ListBox1Click(Sender: TObject);

              var

              strValue: string; { Holds the alias selected by the user }

              bIsLocal: Boolean; { Indicates whether or not an alias is local }

              slParams: TStringList; { Holds the parameters of the selected alias }

              iCounter: Integer; { An integer counter variable for loops}

              begin

              { Determine the alias name selected by the user }

              with ListBox1 do

              strValue := Items.Strings[ItemIndex];

              { Get the names of the tables in the alias and put them in the

              appropriate list box, making sure the user's choices are reflected

              in the list. }

              ListBox2.Items.Clear;

              Session.GetTableNames(strValue, { alias to enumerate }

              '', { pattern to match }

              CheckBox1.Checked, { show extensions flag }

              CheckBox2.Checked, { show system tables flag }

              ListBox2.Items); { target for table list }

              { Make sure there are tables defined in the alias. If not, show an

              error; otherwise, clear the list box. }

              Screen.Cursor := crDefault;

              if ListBox2.Items.Count < 1 then

              MessageDlg('There are no tables in the alias you selected. Please

              choose another', mtError, [mbOK], 0 );

              ListBox3.Items.Clear;

              end;

              procedure TQueryForm.ListBox2Click(Sender: TObject);

              begin

              Screen.Cursor := crHourglass;

              try

              { First, disable the TTable object. }

              if Table1.Active then

              Table1.Close;

              { Open the selected table }

              with ListBox1 do

              Table1.DatabaseName := Items.Strings[ItemIndex];

              with ListBox2 do

              Table1.TableName := Items.Strings[ItemIndex];

              { Open the table and put a list of the field names in the Fields

              list box. }

              Table1.Open;

              if Table1.Active then

              Table1.GetFieldNames(ListBox3.Items);

              finally

              Screen.Cursor := crDefault;

              end;

              end;

              procedure TQueryForm.BitBtn2Click(Sender: TObject);

              var

              strAlias, { Alias name selected by the user }

              strTable, { Table name selected by the user }

              strField, { Field name selected by the user }

              strValue, { Field Value entered by the user }

              strWhere, { WHERE clause for the user's query }

              strQuote, { Holds quotes is the query field is text }

              strQuery: string; { String used to construct the query }

              frmQuery: TResultForm; { The Results form }

              type

              { The following type is used with the Type drop-down

              list. The text values corresponding with each item is

              described in comments, along with the relevant SQL operators. }

              etSQLOps = (soNoCondition, { not field conditions: no WHERE clause }

              soEqual, { equals: = }

              soNotEqual, { is not equal to: <> }

              soLessThan, { is less than: < }

              soLessEqual, { is less than or equal to: <= }

              soMoreThan, { is greater than: > }

              soMoreEqual, { is greater than or equal to: >= }

              soStartsWith, { starts with: LIKE xx% }

              soNoStartsWith, { doesn't start with: NOT LIKE xx% }

              soEndsWith, { ends with: LIKE %xx }

              soNoEndsWith, { doesn't end with: NOT LIKE %xx }

              soContains, { contains: LIKE %xx% }

              soNoContains, { doesn't contain: NOT LIKE %xx% }

              soBlank, { is blank: }

              soNotBlank, { is not blank: }

              soInside, { contains only: IN ( xx, yy, zz ) }

              soOutside); { doesn't contain: NOT IN (xx, yy, zz) }

              begin

              { Initialize the variables needed to run the query }

              with ListBox1 do

              if ItemIndex = -1 then

              raise Exception.Create('Can''t Run Query: No Alias Selected')

              else

              strAlias := Items.Strings[ItemIndex];

              with ListBox2 do

              if ItemIndex = -1 then

              raise Exception.Create('Can''t Run Query: No Table Selected')

              else

              strTable := Items.Strings[ItemIndex];

              with ListBox3 do

              if ItemIndex = -1 then

              begin

              if ComboBox1.ItemIndex > Ord(soNocondition) then

              raise Exception.Create('Can''t Run Query: No Field Selected')

              else

              strField := '';

              end

              else

              strField := Items.Strings[ItemIndex];

              if (Edit1.Text = '') and

              (ComboBox1.ItemIndex > Ord(soNoCondition)) and

              (ComboBox1.ItemIndex < Ord(soBlank)) then

              raise Exception.create('Can''t Run Query: No Search Value Entered')

              else

              strValue := Edit1.Text;

              { See if the field being search is a string field. If so, then pad the

              quote string with quotation marks; otherwise, set it to a null value. }

              if strField <> '' then

              with Table1.FieldByName(strField) do

              if (DataType = ftString) or (DataType = ftMemo) then

              strQuote := '"' else

              strQuote := '';

              { Construct the WHERE clause of the query based on the user's choice

              in Type. }

              case etSQLOps(ComboBox1.ItemIndex) of

              soNoCondition: strWhere := '';

              soEqual: strWhere := strField + ' = ' + strQuote + strValue+ strQuote;

              soNotEqual: strWhere := strField + ' <> ' + strQuote + strValue +

              strQuote;

              soLessThan: strWhere := strField + ' < ' + strQuote + strValue +

              strQuote;

              soLessEqual: strWhere := strField + ' <= ' + strQuote + strValue +

              strQuote;

              soMoreThan: strWhere := strField + ' > ' + strQuote + strValue +

              strQuote;

              soMoreEqual: strWhere := strField + ' >= ' + strQuote + strValue +

              strQuote;

              soStartsWith: strWhere := strField + ' LIKE ' + strQuote +

              strValue + '%' + strQuote;

              soNoStartsWith: strWhere := strField + ' NOT LIKE ' + strQuote +

              strValue + '%' + strQuote;

              soEndsWith: strWhere := strField + ' LIKE ' + strQuote +

              '%' + strValue + strQuote;

              soNoEndsWith: strWhere := strField + ' NOT LIKE ' +

              strQuote + '%' + strValue + strQuote;

              soContains: strWhere := strField + ' LIKE '+ strQuote+'%'+ strValue

              + '%' + strQuote;

              soNoContains: strWhere := strField + ' NOT LIKE ' + strQuote + '%'

              + strValue + '%' + strQuote;

              soBlank: strWhere := strField + ' IS NULL';

              soNotBlank: strWhere := strField + ' IS NOT NULL';

              end;

              if ComboBox1.ItemIndex = Ord(soNoCondition) then

              strQuery := 'SELECT * FROM "' + strTable + '"'

              else if Table1.FieldByName(strField).DataType = ftString then

              strQuery := 'SELECT * FROM "' + strTable + '" t WHERE t.' + strWhere

              else

              strQuery := 'SELECT * FROM "' + strTable + '" t WHERE t.' + strWhere;

              { Create an instance of the browser form. }

              frmQuery := TResultForm.Create(Application);

              { Use a resource protection block in case an exception is raised. This

              ensures that the memory allocated for the Results form is released. }

              try

              with frmQuery do

              begin

              Screen.Cursor := crHourglass;

              if Query1.Active then Query1.Close;

              Query1.DatabaseName := strAlias; {set the alias the query poitns to}

              Query1.SQL.clear; { empty existing SQL in the query }

              Query1.SQL.Add(strQuery); { add query string to query object }

              Query1.Active := True; { try to run the query }

              Screen.Cursor := crDefault;

              if Query1.Active then

              begin

              { If the query didn't return any records, there's no point in

              displaying the form. In that event, raise an exception. }

              if Query1.RecordCount < 1 then

              raise Exception.create('No records matched your criteria.

              Please try again.' );

              { write a message to the browse form's status line }

              if strField = '' then

              Panel3.Caption := 'Now showing all records from ' + strTable

              + '...'

              else

              Panel3.Caption := 'Now showing '+ strTable +' where '+ strField

              +' contains values equal to '+ strValue + '...';

              { show the form }

              ShowModal;

              end;

              end;

              finally

              frmQuery.Free;

              end;

              end;

              end.

              unit RSLTFORM;

              interface

              uses

              SysUtils, Windows, Messages, Classes, Graphics, Controls, StdCtrls, DB,

              Forms, DBCtrls, DBGrids, DBTables, Buttons, Grids, ExtCtrls, Dialogs;

              type

              TResultForm = class(TForm)

              DBGrid1: TDBGrid;

              DBNavigator: TDBNavigator;

              Panel1: TPanel;

              DataSource1: TDataSource;

              Panel2: TPanel;

              Panel3: TPanel;

              Query1: TQuery;

              SpeedButton2: TSpeedButton;

              Panel4: TPanel;

              SpeedButton1: TSpeedButton;

              procedure SpeedButton1Click(Sender: TObject);

              procedure SpeedButton2Click(Sender: TObject);

              end;

              var

              ResultForm: TResultForm;

              implementation

              {$R *.DFM}

              procedure TResultForm.SpeedButton1Click(Sender: TObject);

              begin

              Close;

              end;

              procedure TResultForm.SpeedButton2Click(Sender: TObject);

              var

              strText: string; { Variable to hold display text }

              iCounter: Integer; { Loop counter variable }

              begin

              { Build a string containing the query }

              strText := '';

              for iCounter := 0 to Query1.SQL.Count - 1 do

              strText := strText + Query1.SQL[iCounter];

              { Display the query text }

              MessageDlg('The underlying query is: ' + #10 + #10 + strText,

              mtInformation, [mbOK], 0 );

              end;

              end.

            上一頁  1 2 3 4 5 6 7 8  下一頁
              相關(guān)推薦:2010年9月計(jì)算機(jī)等級(jí)考試試題及答案解析專題
                   預(yù)告:名師解析2010年9月計(jì)算機(jī)等級(jí)考試試題答案
                   2010年9月計(jì)算機(jī)等級(jí)考試成績查詢時(shí)間及入口
                   2010年9月計(jì)算機(jī)等考成績查詢短信免費(fèi)提醒開通
            文章搜索
            版權(quán)聲明:如果計(jì)算機(jī)等級(jí)考試網(wǎng)所轉(zhuǎn)載內(nèi)容不慎侵犯了您的權(quán)益,請與我們聯(lián)系800@exam8.com,我們將會(huì)及時(shí)處理。如轉(zhuǎn)載本計(jì)算機(jī)等級(jí)考試網(wǎng)內(nèi)容,請注明出處。