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

📄 unit1.cpp

📁 <<C++Builder 6实用编程100例>>随书光盘
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
        TStringList *pSL=new TStringList();
        Session->GetDatabaseNames(pSL);
        ListBox1->Items->Assign(pSL);
        delete pSL;

}
//---------------------------------------------------------------------------

void __fastcall TForm1::ListBox1Click(TObject *Sender)
{
        try
        {
                AnsiString s;
                ListBox2->Items->Clear();
                ListBox3->Items->Clear();
                s=ListBox1->Items->Strings[ListBox1->ItemIndex];
                Session->GetTableNames(s,"",true,false,ListBox2->Items);
        }
        catch(...)
        {
                ShowMessage("抱歉,该数据库无法打开。请重新进行选择!");
        }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ListBox2Click(TObject *Sender)
{
        AnsiString sDBName,sTBName;
        TTable *tb=new TTable(this);
        int i;
        sDBName=ListBox1->Items->Strings[ListBox1->ItemIndex];
        sTBName=ListBox2->Items->Strings[ListBox2->ItemIndex];
        tb->DatabaseName=sDBName;
        tb->TableName=sTBName;
        tb->Open();
        ListBox3->Items->Clear();
        for(i=0;i<tb->FieldCount;i++)
                ListBox3->Items->Add(tb->Fields->Fields[i]->FieldName);
        tb->Close();
        delete tb;
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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