数据库备份 (100分)

  • 主题发起人 主题发起人 xiaod
  • 开始时间 开始时间
X

xiaod

Unregistered / Unconfirmed
GUEST, unregistred user!
你把 数据备份的例子发送到以下信箱,
onlyonekgx@163.com
我可以给你两百分,
我先给你一百分,
待收到后再给你一百分
 
就要他的呀
 
谁的都可以,待遇一样
 
要Access 还是Sql server的
给你 sql server的
{*******************************************************}
{ }
{ 数据库的操作及把连接字符串写进注册表 }
{ 作者:antic_ant }
{ }
{ 日期:2002-09-10 }
{ 引用了SQLDMO_TLB单元,只有安装sql server才能引入 }
{ 如果不delphi引入则须把dcu文件加入到工程中即可 }
{ }
{*******************************************************}
unit Umain;

interface

uses
Windows, Messages, SysUtils, Variants,SQLDMO_TLB,Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;

type
TFrmDataManager = class(TForm)
PnlTitle: TPanel;
ImgTitle: TImage;
LblTitle1: TLabel;
LblTitle2: TLabel;
ImgServer: TImage;
CmbxServer: TComboBox;
LblServer: TLabel;
BvlCon: TBevel;
LblConnection: TLabel;
RadioBtnWin: TRadioButton;
RadioBtnSql: TRadioButton;
LblUser: TLabel;
LblPassWord: TLabel;
EdtUser: TEdit;
EdtPassWord: TEdit;
LblDatabase: TLabel;
BvlData: TBevel;
LblDatabaseLst: TLabel;
CmbxDatabase: TComboBox;
BvlOperate: TBevel;
BtnConnection: TButton;
BtnBackUp: TButton;
BtnRestore: TButton;
BtnExit: TButton;
SaveDlg: TSaveDialog;
OpenDlg: TOpenDialog;
procedure BtnExitClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure RadioBtnWinClick(Sender: TObject);
procedure RadioBtnSqlClick(Sender: TObject);
procedure BtnConnectionClick(Sender: TObject);
procedure CmbxDatabaseDropDown(Sender: TObject);
procedure CmbxDatabaseCloseUp(Sender: TObject);
procedure BtnBackUpClick(Sender: TObject);
procedure BtnRestoreClick(Sender: TObject);
private
{ Private declarations }
procedure SetBtnState(value:Boolean);
procedure SetEdtState;
public
{ Public declarations }
Connected:boolean;
end;

var
FrmDataManager: TFrmDataManager;
App:_application;
Backup :_Backup;
Restore :_Restore;

implementation

uses reg;

{$R *.dfm}

procedure TFrmDataManager.BtnExitClick(Sender: TObject);
begin
Close;
end;

procedure TFrmDataManager.SetBtnState(value: Boolean);
begin
BtnBackUp.Enabled:=Value;
BtnRestore.Enabled:=Value;
end;

procedure TFrmDataManager.SetEdtState;
begin
EdtUser.Enabled:=False;
EdtPassWord.Enabled:=False;
EdtUser.Color:=clBtnFace;
EdtPassWord.Color:=clBtnFace;
if RadioBtnSql.Checked then
begin
EdtUser.Enabled:=True;
EdtPassWord.Enabled:=True;
EdtUser.Color:=clWhite;
EdtPassWord.Color:=clWhite;
end;
end;

procedure TFrmDataManager.FormCreate(Sender: TObject);
var
i:integer;
nl:namelist;
Server:_sqlserver;
begin
Connected:=False;
BtnConnection.Enabled:=False;
SetBtnState(Connected);
App:=coapplication.Create;
Server:=cosqlserver.Create ;
nl:=App.ListAvailableSQLServers;
CmbxServer.Clear;
for i:=0 to nl.Count-1 do
begin
CmbxServer.Items.Add(nl.Item(i+1) )
end;
CmbxServer.ItemIndex:=0;
end;

procedure TFrmDataManager.RadioBtnWinClick(Sender: TObject);
begin
SetEdtState;
end;

procedure TFrmDataManager.RadioBtnSqlClick(Sender: TObject);
begin
SetEdtState;
end;

procedure TFrmDataManager.BtnConnectionClick(Sender: TObject);
var
ConStr:string;
begin
Connected:=False;

if RadioBtnWin.Checked then
begin
ConStr:=BaseConStr+'Integrated Security=SSPI;Persist Security Info=False;'+
'Initial Catalog='+CmbxDatabase.Text +';Data Source='+
CmbxServer.Text;
end
else
begin
ConStr:=BaseConStr+'Password='+EdtPassWord.Text
+';Persist Security Info=True;User ID='+EdtUser.Text
+';Initial Catalog='+CmbxDatabase.Text
+';Data Source='+CmbxServer.Text;
end;

Connected:=True;
{$IFNDEF BizUnit}
SetRegString(HKEY_LOCAL_MACHINE, MyRegSection, MyRegKey_Connection, ConStr);
{$ENDIF}

SetBtnState(Connected);

end;

procedure TFrmDataManager.CmbxDatabaseDropDown(Sender: TObject);
var
i:integer;
Server:_sqlserver;
Dtbase:_database;
begin
BtnConnection.Enabled:=False;
Server:=cosqlserver.Create ;
Dtbase:=codatabase.Create;
CmbxDatabase.Clear;
Server.LoginTimeout:=-1;
Screen.Cursor := crHourGlass;

try
if RadioBtnWin.Checked then
begin
With Server do
begin
LoginSecure:=true;
AutoReConnect:= False;
Connect(CmbxServer.Text,null,null);
end;
end
else
begin
With Server do
begin
LoginSecure := False;
AutoReConnect := False;
Connect(CmbxServer.Text,EdtUser.Text, EdtPassWord.Text);
end;
end;
CmbxDatabase.Clear;
for i:=1 to Server.Databases.Count do
begin
CmbxDatabase.Items.Add(Server.Databases.Item(i,'').Name);
end;

except
Application.MessageBox('连接数据库失败!', PChar(Self.Caption), MB_OK or MB_ICONSTOP);
EdtUser.SetFocus;
end;
Screen.Cursor := crDefault;
end;

procedure TFrmDataManager.CmbxDatabaseCloseUp(Sender: TObject);
begin
if CmbxDatabase.ItemIndex>=0 then BtnConnection.Enabled:=True;
end;

procedure TFrmDataManager.BtnBackUpClick(Sender: TObject);
var
Server:_sqlserver;
Backup:_Backup;
begin
Server:=cosqlserver.Create ;
Server.LoginTimeout:=-1;
if SaveDlg.Execute then
begin
try
Screen.Cursor := crHourGlass;
if RadioBtnWin.Checked then
begin
With Server do
begin
LoginSecure:=true;
AutoReConnect:= False;
Connect(CmbxServer.Text,null,null);
end;
end
else
begin
With Server do
begin
LoginSecure := False;
AutoReConnect := False;
Connect(CmbxServer.Text,EdtUser.Text, EdtPassWord.Text);

end;
end;


Backup :=coBackup.Create ;
Backup.action:=SQLDMOBackup_DATABASE;
Backup.Database:=CmbxDatabase.Text;
Backup.Files := SaveDlg.FileName;

Backup.SQLBackup(Server);
Screen.Cursor := crDefault;
Application.MessageBox(PChar('数据库 '+CmbxDatabase.Text +' 备份成功'), PChar(Self.Caption), MB_OK or MB_ICONINFORMATION);
except
Screen.Cursor := crDefault;
Application.MessageBox(PChar('数据库 '+CmbxDatabase.Text+' 备份失败'), PChar(Self.Caption), MB_OK or MB_ICONSTOP);
end;

Screen.Cursor := crDefault;
end;
end;

procedure TFrmDataManager.BtnRestoreClick(Sender: TObject);
var
Server:_sqlserver;
Restore:_Restore;
begin
Server:=cosqlserver.Create ;
Server.LoginTimeout:=-1;
if OpenDlg.Execute then
begin
try
Screen.Cursor := crHourGlass;
if RadioBtnWin.Checked then
begin
With Server do
begin
LoginSecure:=true;
AutoReConnect:= False;
Connect(CmbxServer.Text,null,null);
end;
end
else
begin
With Server do
begin
LoginSecure := False;
AutoReConnect := False;
Connect(CmbxServer.Text,EdtUser.Text, EdtPassWord.Text);
end;
end;

Restore :=coRestore.create;
Restore.Replacedatabase:=true;
Restore.action:=SQLDMORESTORE_DATABASE;
Restore.Database:=CmbxDatabase.Text;
Restore.Files := OpenDlg.FileName;
Restore.SQLRestore(Server);
Screen.Cursor := crDefault;
Application.MessageBox(PChar('数据库 '+CmbxDatabase.Text +' 恢复成功'), PChar(Self.Caption), MB_OK or MB_ICONINFORMATION);
except
Screen.Cursor := crDefault;
Application.MessageBox(PChar('数据库 '+CmbxDatabase.Text+' 恢复失败'), PChar(Self.Caption), MB_OK or MB_ICONSTOP);
end;

Screen.Cursor := crDefault;
end;
end;

end.
 
Oracle的怎么备份?
 
请问四楼的兄弟,我这装了SQL2000,怎么找不到
SQLDMO_TLB.DCU文件? MIKEAWEN@SOHU.COM
 
我也给你一份,不过我看了一下,你好象只有200分了,假如,有两个人发了,你怎么给,
废话少说,access的,
unit UMyTest;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls,ADOX_TLB, DBTables, Buttons, ComCtrls,
ExtCtrls;

type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
ADOConnection2: TADOConnection;
ADODataSet1: TADODataSet;
ADODataSet2: TADODataSet;
Button3: TButton;
Label1: TLabel;
OpenDialog1: TOpenDialog;
OpenDialog2: TOpenDialog;
Button1: TButton;
Button2: TButton;
ProgressBar1: TProgressBar;
StatusBar1: TStatusBar;
Label4: TLabel;
Edit2: TEdit;
Bevel1: TBevel;
SaveDialog1: TSaveDialog;
Button4: TButton;
Edit1: TEdit;
Label2: TLabel;
Edit3: TEdit;
Procedure GetTableData(TableName : Table ; ExamTableName : Table) ;
Procedure GetData(TableName : Table ;ExamTableName : Table) ;
procedure FormDestroy(Sender: TObject);
function GetADOXFieldType(aType: DataTypeEnum): string ;
procedure Button3Click(Sender: TObject);
procedure GetAdoField(TableName : Table ;ExamTableName : Table ) ;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure GetTable ;
procedure GetTableStructuer ;
// Procedure ChangeName ;
private
adoxTable : Table ;
adoxTables : Tables ;
adoxColumns : Columns ;
adoxColumn : Column ;
adoxCatalog : Catalog ;


adoxTable1 : Table ;
adoxTables1 : Tables ;
adoxColumns1 : Columns ;
adoxColumn1 : Column ;
adoxCatalog1 : Catalog ;
Procedure GetAllData ;
Procedure GetSysTableData(TableName : Table ; ExamTableName : Table) ;
{ Private declarations }
public
strName : string ;
str : string ;
{ Public declarations }
end;

var
Form1: TForm1;

implementation


{$R *.dfm}




procedure TForm1.GetTableData(TableName : Table ; ExamTableName : Table) ;
var
adoxpros : Properties ;
adoxpro : Property_ ;
i,ipro : integer ;
begin
strName := '' ;

if ADODataSet1.Active then
ADODataSet1.Active := False ;
with ADODataSet1 do
begin
CommandType := cmdText ;
CommandText := 'select * from '+ TableName.Name ;
open ;
end ;

adoxcolumns := TableName.Columns ; //原数据
adoxcolumns1 := ExamTableName.Columns ; //目标数据

For i := 0 to adoxColumns1.Count -1 do
begin
adoxColumn1 := adoxColumns1.Item ;

adoxpros := adoxColumn1.Properties ;
For ipro := 0 to adoxpros.Count -1 do
begin
adoxpro := adoxpros.Item[ipro] ;
if adoxpro.Value = true then
begin
strName := adoxColumn1.Name ;
break ;
end
else
break ;
end ;
if strname <>'' then
break ;
end ;

if ADODataSet2.Active then
ADODataSet2.Active := False ;
with ADODataSet2 do
begin
CommandType := cmdText ;
CommandText := ' select * from '+ ExamTableName.Name ;
Open ;
end ;

if strName <> '' then
begin
if ADODataSet1.Active then
ADODataSet1.Active := False ;
with ADODataSet1 do
begin
CommandType := cmdText ;
CommandText := 'select * from ' +TableName.Name + #32+ 'order by'+ #32 + strName ;
open ;
end ;

if ADODataSet2.Active then
ADODataSet2.Active := False ;
with ADODataSet2 do
begin
CommandType := cmdText ;
CommandText := 'select * from ' +ExamTableName.Name + #32+ 'order by'+ #32 + strName ;
open ;
end ;
end ;
end;
// 取到数据
procedure TForm1.GetData(TableName : Table ;ExamTableName : Table);
begin
//
str := '' ;
ADODataSet1.First ;
while not ADODataSet1.Eof do
begin
GetAdoField(TableName,ExamTableName);
//
if strName <> '' then
if ADODataSet1.FieldValues[strName]< ADODataSet2.FieldValues[strName] then
begin
if MessageDlg('数据模板的数据错误,重新下载新的模板',mtInformation, [mbok], 0) = mrok then
begin
str := 'MyData' ;
break ;
end ;
end ;
//
if strName <> '' then
{ if ADODataSet2.Locate(strName,ADODataSet1.FieldValues[strName],[]) = False then
begin
ADODataSet2.Delete ;
GetAdoField(TableName,ExamTableName);
end ; }
while ADODataSet1.FieldValues[strName]<>ADODataSet2.FieldValues[strName] do
begin
ADODataSet2.Delete ;
GetAdoField(TableName,ExamTableName);
end ;
application.ProcessMessages ;
ADODataSet1.Next ;
end ;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
adoxCatalog := nil ;
adoxCatalog1 := nil;
end;

function TForm1.GetADOXFieldType(aType: DataTypeEnum): string;
begin
case aType of
adEmpty : Result := 'adEmpty' ;
adTinyInt : Result := 'adTinyInt' ;
adSmallInt : Result := 'adSmallInt' ;
adInteger: Result := 'adInteger';
adBigInt: Result := 'adBigInt';
adUnsignedTinyInt: Result := 'adUnsignedTinyInt';
adUnsignedSmallInt: Result := 'adUnsignedSmallInt';
adUnsignedInt: Result := 'adUnsignedInt';
adUnsignedBigInt: Result := 'adUnsignedBigInt';
adSingle: Result := 'adSingle';
adDouble: Result := 'adDouble';
adCurrency: Result := 'adCurrency';
adDecimal: Result := 'adDecimal';
adNumeric: Result := 'adNumeric';
adBoolean: Result := 'adBoolean';
adError: Result := 'adError';
adUserDefined: Result := 'adUserDefined';
adVariant: Result := 'adVariant';
adIDispatch: Result := 'adIDispatch';
adIUnknown: Result := 'adIUnknown';
adGUID: Result := 'adGUID';
adDate: Result := 'adDate';
adDBDate: Result := 'adDBDate';
adDBTime: Result := 'adDBTime';
adDBTimeStamp: Result := 'adDBTimeStamp';
adBSTR: Result := 'adBSTR';
adChar: Result := 'adChar';
adVarChar: Result := 'adVarChar';
adLongVarChar: Result := 'adLongVarChar';
adWChar: Result := 'adWChar';
adVarWChar: Result := 'adVarWChar';
adLongVarWChar: Result := 'adLongVarWChar';
adBinary: Result := 'adBinary';
adVarBinary: Result := 'adVarBinary';
adLongVarBinary: Result := 'adLongVarBinary';
adChapter: Result := 'adChapter';
adFileTime: Result := 'adFileTime';
adPropVariant: Result := 'adPropVariant';
adVarNumeric: Result := 'adVarNumeric';
end ;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
GetAllData ;
end;

procedure TForm1.GetAdoField(TableName, ExamTableName: Table);
var
i : Integer ;
iColumn : integer ;
begin
adoxcolumns := TableName.Columns ; //原数据
adoxcolumns1 := ExamTableName.Columns ; //目标数据
//数据的插入
ADODataSet2.Insert;
//根据表取得字段
For i := 0 to adoxColumns1.Count -1 do
begin
for icolumn := 0 to adoxColumns.Count -1 do
begin
adoxColumn1 := adoxColumns1.Item ;
adoxColumn := adoxColumns.Item[icolumn] ;
// 如果字段相同
if adoxColumn.Name = adoxColumn1.Name then
begin
//
if strName <> adoxColumn.Name then
begin
//插入
ADODataSet2.FieldValues[adoxColumn.Name] := ADODataSet1.FieldValues[adoxColumn.Name] ;
end ;
break ;
end ;
end ;
end ;
ADODataSet2.Post ;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
Dsnstr : String ;
begin
Edit3.Text := '' ;
if ADOConnection1.Connected then
ADOConnection1.Connected := False ;
if OpenDialog1.Execute then
begin
Dsnstr := 'Password=wearewinners;User ID=wisenter;'
+ ' Data Source='+ OpenDialog1.FileName +';'
+ ' Mode=Share Deny None;Extended Properties=""; '
+ ' Jet OLEDB:System database=system.mdw;'
+ ' Jet OLEDB:Registry Path="";'
+ ' Jet OLEDB:Database Password="";'
+ ' Jet OLEDB:Engine Type=5;'
+ ' Jet OLEDB:Database Locking Mode=1;'
+ ' Jet OLEDB:Global Partial Bulk Ops=2;'
+ ' Jet OLEDB:Global Bulk Transactions=1;'
+ ' Jet OLEDB:New Database Password="";'
+ ' Jet OLEDB:Create System Database=False;'
+ ' Jet OLEDB:Encrypt Database=False;'
+ ' Jet OLEDB:Don''t Copy Locale on Compact=False;'
+ ' Jet OLEDB:Compact Without Replica Repair=False;'
+ ' Jet OLEDB:SFP=False' ;
//
ADOConnection1.ConnectionString := Dsnstr;
ADOConnection1.LoginPrompt := False ;
Edit3.Text := OpenDialog1.FileName ;
try
ADOConnection1.Connected := True;
except
Application.MessageBox(pchar('数据库出错,打开数据库失败' ),
'错误', MB_OK or MB_ICONWARNING);
Halt;
end;
end ;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
Dsnstr : String ;
FromF, ToF: file;
NumRead, NumWritten: Integer;
Buf: array[1..2048] of Char;
strN : string ;
begin
Edit2.Text := '' ;
if ADOConnection2.Connected then
ADOConnection2.Connected := False ;

if OpenDialog2.Execute then
begin
AssignFile(FromF,OpenDialog2.FileName);
Reset(FromF,1) ;

strN := Edit1.Text + '.wsd' ;
if strN = '' then
ShowMessage('先输入要保存的名字!!!');
AssignFile(ToF,strN);
Rewrite(ToF,1) ;

repeat
BlockRead(FromF, Buf, SizeOf(Buf), NumRead);
BlockWrite(ToF, Buf, NumRead, NumWritten);
until (NumRead = 0) or (NumWritten <> NumRead);

CloseFile(FromF);
CloseFile(ToF);
//
Edit2.Text := OpenDialog2.FileName ;
//
Dsnstr := 'Password=wearewinners;User ID=wisenter;'
+ ' Data Source='+ strN +';'
+ ' Mode=Share Deny None;Extended Properties=""; '
+ ' Jet OLEDB:System database=system.mdw;'
+ ' Jet OLEDB:Registry Path="";'
+ ' Jet OLEDB:Database Password="";'
+ ' Jet OLEDB:Engine Type=5;'
+ ' Jet OLEDB:Database Locking Mode=1;'
+ ' Jet OLEDB:Global Partial Bulk Ops=2;'
+ ' Jet OLEDB:Global Bulk Transactions=1;'
+ ' Jet OLEDB:New Database Password="";'
+ ' Jet OLEDB:Create System Database=False;'
+ ' Jet OLEDB:Encrypt Database=False;'
+ ' Jet OLEDB:Don''t Copy Locale on Compact=False;'
+ ' Jet OLEDB:Compact Without Replica Repair=False;'
+ ' Jet OLEDB:SFP=False' ;
ADOConnection2.ConnectionString := Dsnstr;
ADOConnection2.LoginPrompt := False ;
//ListBox2.Items.Add(OpenDialog2.FileName) ;
try
ADOConnection2.Connected := True;
except
Application.MessageBox(pchar('数据库出错,打开数据库失败' + #13 + '[状态]'),
'错误,请看read.txt文件', MB_OK or MB_ICONWARNING);
Halt;
end;
end ;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
if SaveDialog1.Execute then
Edit1.Text := SaveDialog1.FileName ;
end;

procedure TForm1.GetTable;
begin
ADODataSet2.First ;
while not ADODataSet2.Eof do
begin
if strName <> '' then
if ADODataSet1.Locate('Parameter_Item',ADODataSet2.FieldValues['Parameter_Item'],[]) then
begin
ADODataSet2.Edit ;
if ADODataSet2.Fieldvalues['Parameter_Item']<>'DB_Version' then
begin
ADODataSet2.Fieldvalues['value'] := ADODataSet1.FieldValues['value'] ;
end ;
ADODataSet2.post ;
end ;
ADODataSet2.Next ;
end ;
end;

procedure TForm1.GetTableStructuer;
begin
ADODataSet2.First ;
while not ADODataSet2.Eof do
begin
if ADODataSet1.Locate('TableName',ADODataSet2.FieldValues['TableName'],[]) then
begin
ADODataSet2.Edit ;
ADODataSet2.FieldValues['DictName'] := ADODataSet1.FieldValues['DictName'] ;
ADODataSet2.Post ;
end ;
ADODataSet2.Next ;
end ;
end;



procedure TForm1.GetAllData;
var
i,int : integer ;
iView : integer ;
adoxViews1 : views ;
adoxview1 : view ;
viewName : string ;
begin
//建立原生接口,
adoxCatalog := CoCatalog.Create ;
adoxCatalog1 := CoCatalog.Create ;
//连接数据库

adoxCatalog.Set_ActiveConnection(ADOConnection1.ConnectionObject);
adoxCatalog1.Set_ActiveConnection(ADOConnection2.ConnectionObject); //新库
//生成表
adoxTables1 := adoxCatalog1.Tables ;
adoxTables := adoxCatalog.Tables ;
//生成视图
adoxViews1 := adoxCatalog1.Views ;
//
ProgressBar1.Max := adoxTables1.Count ;
ProgressBar1.Min := 0 ;
//
For int := 0 to adoxTables1.Count - 1 do
begin

// ShowMessage(adoxTable1.Name);
For i := 0 to adoxTables.Count -1 do
begin
adoxTable1 := adoxTables1.Item[int] ;
adoxTable := adoxTables.Item ;

viewName := '' ;
//如果是系统表就不处理
if (adoxTable1.Name = 'DictStructure')or (adoxTable1.Name = 'System_Parameter')or(adoxTable1.Name ='MSysAccessObjects') or (adoxTable1.Name = 'MSysAccessXML')or (adoxTable1.Name = 'MSysACEs') or (adoxTable1.Name = 'MSysObjects') or (adoxTable1.Name = 'MSysQueries')or (adoxTable1.Name = 'MSysRelationships')then
begin
if adoxTable1.Name = 'DictStructure'then
begin
GetTableData(adoxTable1,adoxTable1) ;
GetTableStructuer ;
end ;
if adoxTable1.Name = 'System_Parameter' then
begin
GetSysTableData(adoxTable1,adoxTable1) ;
GetTable ;
end ;
break ;
end
else begin
//表相同
if adoxTable.Name = adoxTable1.Name then
begin
//判断视图
For iView := 0 to adoxviews1.Count -1 do
begin
adoxview1 := adoxviews1.Item[iView] ;
//如果是视图
if adoxTable.Name = adoxview1.Name then
begin
viewName := adoxTable.Name ;
break ;
end ;
end ;
//如果不是视图
if adoxTable.Name <> viewName then
begin
//启动数据集

GetTableData(adoxTable1,adoxtable) ;
//
ProgressBar1.Position := int +2 ;
ProgressBar1.Update ;
//取道数据
GetData(adoxTable,adoxTable1);
end ;
Break ;
end ;
end ;
end ;
if str = 'MyData' then
break ;
end ;
if str = 'MyData' then
begin
Application.Terminate ;
end
else begin
if MessageDlg('数据升级完毕!!!',mtInformation, [mbok], 0) = mrok then
Application.Terminate ;
end ;
end;


procedure TForm1.GetSysTableData(TableName, ExamTableName: Table);
var
adoxpros : Properties ;
adoxpro : Property_ ;
i,ipro : integer ;
begin
strName := '' ;
// showmessage(strName) ;
if ADODataSet1.Active then
ADODataSet1.Active := False ;
with ADODataSet1 do
begin
CommandType := cmdText ;
CommandText := 'select * from '+ TableName.Name ;
open ;
end ;

adoxcolumns := TableName.Columns ; //原数据
adoxcolumns1 := ExamTableName.Columns ; //目标数据

For i := 0 to adoxColumns1.Count -1 do
begin
adoxColumn1 := adoxColumns1.Item ;
//判断属性
// ShowMessage(adoxColumn1.Name) ;

adoxpros := adoxColumn1.Properties ;
For ipro := 0 to adoxpros.Count -1 do
begin
adoxpro := adoxpros.Item[ipro] ;
//如果为true就为自增行
// ShowMessage(adoxpro.Value);
if adoxpro.Value = true then
begin
strName := adoxColumn1.Name ;
break ;
end
else
break ;
end ;
if strname <>'' then
break ;
end ;

if ADODataSet2.Active then
ADODataSet2.Active := False ;
with ADODataSet2 do
begin
CommandType := cmdText ;
CommandText := ' select * from '+ ExamTableName.Name ;
Open ;
end ;

if strName <> '' then
begin
// ShowMessage('ddd');
if ADODataSet1.Active then
ADODataSet1.Active := False ;
with ADODataSet1 do
begin
CommandType := cmdText ;
CommandText := 'select * from ' + TableName.Name ;
open ;
end ;

if ADODataSet2.Active then
ADODataSet2.Active := False ;
with ADODataSet2 do
begin
CommandType := cmdText ;
CommandText := 'select * from ' + ExamTableName.Name + #32+ 'order by'+ #32 + strName ;
open ;
end ;
end ;
end;

end.


 
程序比较长!是我刚刚做的一个,用adox做的,
有什么问题,可以和我联系,
h1yn@163.com
 
如果是备份ACCESS完全不用上面那位兄弟的那样麻烦。

几句就搞定了。因为ACCESS数据库其实就是一个MDB文件,把这个文件
备份就行了。简单点说就是把一个文件拷贝到一个指定位置。

引用单元IdGlobal。
假设你的数据库在你的程序目录中的DATA子目录中(我经常这样)
var AppPath :string;
begin
AppPath := ExtractFilePath(Application.ExeName);
CopyFileTo(AppPath+'/data/mydata.mdb', '备份路径/备份文件');
end;

搞定!
end;
 
备份SQL SERVER数据库直接用它带的命令备份就是了
“dump database”+。。。
就是了,最简单的。
 
谁执行过 antic_ant 关于sql server备份的那段代码
其中单元引用
uses里 SQLDMO_TLB单元在delphi7里好像没有
请高手指点
 
to : 娃娃
我那个程序,除了有数据倍份的功能,还有数据导的功能,
旧的数据库中的数据导到新的库中。。。
两者的要求只要是表名相同就可以了:)
 
这个就稍微麻烦一点,就是要手动建立一个数据库连接,
连到你的备份文件上,然后把数据导过来就是了。

具体的代码,你自己看着写吧,如果有问题再找我。
computer@deruntex.com
 
SQLDMO_TLB在哪呢?
 
后退
顶部