📄 tablemanfrm.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "TableManFrm.h"
#include "MainDm.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "BaseFrm"
#pragma resource "*.dfm"
TfrmTableMan *frmTableMan;
//---------------------------------------------------------------------------
__fastcall TfrmTableMan::TfrmTableMan(TComponent* Owner)
: TfrmBase(Owner)
{}
//---------------------------------------------------------------------------
bool TfrmTableMan::ListAllTable()
{
dmMain->qrySQLPlus->Close();
dmMain->qrySQLPlus->SQL->Clear();
//TStrings * stl = new TStrings;
dmMain->cnnDB->GetTableNames(lsbExistTable->Items, false);
//delete stl;
return true;
}
void __fastcall TfrmTableMan::btnRefreshClick(TObject *Sender)
{
ListAllTable();
}
//---------------------------------------------------------------------------
void __fastcall TfrmTableMan::btnExecClick(TObject *Sender)
{
dmMain->qrySQLPlus->Close();
dmMain->qrySQLPlus->SQL->Clear();
dmMain->qrySQLPlus->SQL->Add(mmoSQL->Text);
if (!chkExec->Checked)
{
dmMain->qrySQLPlus->Open();
int nRow = dmMain->qrySQLPlus->RecordCount;
int nCol = dmMain->qrySQLPlus->Fields->Count;
//grdResult->RowCount = nRow + 1;
grdResult->ColCount = nCol;
dmMain->qrySQLPlus->First();
dmMain->qrySQLPlus->Fields->GetFieldNames(grdResult->Rows[0]);
//String strStatus;
AnsiString str;
str.sprintf("共有记录%d条,字段树目%d个", nRow, nCol);
lblStatus->Caption = str;
#if 0
for (int i = 0; i < nRow; ++i)
{
for (int j = 0; j < nCol; ++j)
{
AnsiString str = Trim(dmMain->qrySQLPlus->Fields->Fields[j]->AsString);
grdResult->Cells[j][i + 1] = str;
}
dmMain->qrySQLPlus->Next();
}
#endif
}
else
{
int nRow = dmMain->qrySQLPlus->ExecSQL();
AnsiString str;
str.sprintf("共有记录%d条影响", nRow);
ListAllTable();
lblStatus->Caption = str;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmTableMan::lsbExistTableDblClick(TObject *Sender)
{
int nIndex = lsbExistTable->ItemIndex;
if (nIndex < 0)
{
return;
}
dmMain->qrySQLPlus->Close();
dmMain->qrySQLPlus->SQL->Clear();
AnsiString strSQL;
strSQL.sprintf("select * from %s", lsbExistTable->Items->Strings[nIndex].c_str());
//ShowMessage(strSQL);
dmMain->qrySQLPlus->SQL->Add(strSQL);
dmMain->qrySQLPlus->Open();
int nRow = dmMain->qrySQLPlus->RecordCount;
int nCol = dmMain->qrySQLPlus->Fields->Count;
//grdResult->RowCount = nRow + 1;
grdResult->ColCount = nCol;
dmMain->qrySQLPlus->First();
dmMain->qrySQLPlus->Fields->GetFieldNames(grdResult->Rows[0]);
//String strStatus;
AnsiString str;
str.sprintf("共有记录%d条,字段数目%d个", nRow, nCol);
lblStatus->Caption = str;
for (int i = 0; i < nRow; ++i)
{
for (int j = 0; j < nCol; ++j)
{
AnsiString str = Trim(dmMain->qrySQLPlus->Fields->Fields[j]->AsString);
grdResult->Cells[j][i + 1] = str;
}
dmMain->qrySQLPlus->Next();
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -