unit1.cpp

来自「使用数据库管理图片-图片直接存入数据库。」· C++ 代码 · 共 85 行

CPP
85
字号
//---------------------------------------------------------------------------

#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::Button1Click(TObject *Sender)
{
ADOTable1->First();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)
{
ADOTable1->Prior();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button3Click(TObject *Sender)
{
ADOTable1->Next();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button4Click(TObject *Sender)
{
ADOTable1->Last();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button5Click(TObject *Sender)
{
ADOTable1->Insert();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button6Click(TObject *Sender)
{
if (! ADOTable1->Eof)
{
if ( Application->MessageBox("确认删除数据?", "注意", MB_YESNO) == IDYES)
{
ADOTable1->Delete();
}
}
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button7Click(TObject *Sender)
{
if (ADOTable1->State==dsEdit)
{
ADOTable1->Post();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button8Click(TObject *Sender)
{
ADOTable1->Cancel();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DBImage1Click(TObject *Sender)
{
//打开【增加相片字段】的文件选取对话框
if (OpenDialog1->Execute())
{
//进入记录编辑模式
ADOTable1->Edit();
//将指定的图片文件加载对应相片字段的Tfield组件内
ADOTable1DSDesigner4->LoadFromFile(OpenDialog1->FileName);
}        
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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