Ls_use='EXEC' + '(' +' USE '" "+ sqlca. Database +') '
The EXECUTE IMMEDIATE: ls_use;
The SQLCA. The AutoCommit=TRUE
Ls_use="EXEC sp_addumpdevice 'disk', '" + name +"', '" + ls_path + "' "//the name of the database name is purpose, ls_path purpose is the path of the database (including the database name)
The EXECUTE IMMEDIATE: ls_use;
Ls_use="BACKUP DATABASE" + sqlca. DATABASE + "TO" + name + "
"The EXECUTE IMMEDIATE: ls_use;
IF the SQLCA. SQLCODE=1 THEN
Messagebox (" system information ", "database backup failed! ~ r ~ n ~ n please check the path to the right or not, ", Stopsign!)
CodePudding user response:
Ha ha, sofa ~ ~You look at the sqlca. Sqlerrtext will know what is wrong, and so on, I write code to you
CodePudding user response:
Exec with USE "master"CodePudding user response:
Grabbing the statements go, try to the database insideCodePudding user response:
The integer li_tempString ls_tip
String ls_sql
String ls_ini
The integer li_filenum
If isnull (as_database) or as_database="" then
The return - 1
End the if
If fileexists (as_backupzip) then
Filedelete (as_backupzip)
End the if
Ls_ini=gs_path + "\ data. Ini"
If keydown (keycontrol!=false then
If gf_deletelog (as_database) & lt; 0 then
If gb_autoback=false then
Messagebox (" prompt ", "delete log failure, can't backup")
End the if
Close (w_busy)
The return - 1
End the if
End the if
If fileexists (ls_ini) then
Filedelete (ls_ini)
End the if
Li_filenum=fileopen (ls_ini linemode! The write! , lockwrite! , append!)
Filewrite (li_filenum, "[the data]")
Filewrite (li_filenum, "version_id=" + as_ver)
Filewrite (li_filenum, "data_name=" + as_dataname)
Filewrite (li_filenum, "dbname=" + as_database)
Filewrite (li_filenum, "data_memo=" + as_memo)
Filewrite (li_filenum, "backup_time=" + string (today (), "yyyy - mm - dd") + "" + string (now ()," HH: mm: SS "))
Fileclose (li_filenum)
As_database ls_sql="backup database" + + "to disk='" + as_backupzip +"' with init;"
The execute immediate: ls_sql using gta_sys;
//li_temp=myzip_addfile (ls_file as_backupzip)
//li_temp=myzip_addfile (ls_ini as_backupzip)
//filedelete (ls_file)
If gta_sys. Sqlcode<> 0 then
If gb_autoback=false then
Messagebox (" prompt ", "data backup failed")
End the if
Close (w_busy)
The return - 1
The else
If gb_autoback=false then
Messagebox (" prompt ", "data backup, backup the files: ~ n" + as_backupzip)
End the if
End the if
Filedelete (ls_ini)
Changedirectory (gs_path)
Return 1
CodePudding user response:
Give you the above functionThe success of the executable
You look at yourself
CodePudding user response:
Ha ha, have a meal, I don't need to write, can be upstairs,You just look at the sqlca. Sqlerrtext information basically can find reasons to solve ~ ~
CodePudding user response:
Posted an article on my "PC",A practical Adaptive Server Anywhere database backup/recovery program
The Adaptive Server Anywhere (ASA) is the original concept (PB) own database management system, manage to make do for small applications of the database Server, an application system, usually in to provide users with simple and practical data backup/restore function, this is a written in PB ASA backup/restore procedures, can be directly used in ASA as small applications of data environment,
One, the backup program
In the text box sle_1 is built on the form, used to display the backup file, and add two buttons: cb_1 (browse), cb_2 (backup), the corresponding event code is as follows:
//cb_1. Clicked ()
String fname, name
GetfileSaveName (' save ', fname, name, "db", "database backup files (*. 1), *. 1 ')
Sle_1. Text=fname
//cb_2. Clicked ()
String mysql, bfname
Bfname=trim (sle_1. Text)
Bfname=left (bfname, len (bfname) - 2)
Mysql="BACKUP DATABASE TO '" + bfname +"' "
The execute immediate: Mysql USING SQLCA;
If the sqlca. Sqlcode=0 then
Messagebox (" message ", 'backup success! 'the information! , OK!
The else
Messagebox (" message ", 'backup failed! 'the information! , OK!
End the if
CodePudding user response:
Second, restore programIn the text box sle_1 is built on the form, display is used to restore the backup file name, and add two buttons: cb_1 (find), cb_2 (recovery), declare a modified file attributes API function:
The FUNCTION ulong SetFileAttributes (ref string lpFileName, ulong dwFileAttributes) LIBRARY "kernel32. DLL" ALIAS FOR "SetFileAttributesA
"The corresponding event code is as follows:
//cb_1. Clicked ()
String fname, name
GetfileOPenName (' lookup 'fname, name, "1", "database backup files (*. 1), * 1")
Sle_1. Text=fname
//cb_2. Clicked ()
String mysql, bfname gzname
Ulong SXZ=32 KB//SXZ for file attribute values, 32, said read-write
Boolean TMP
Bfname=trim (sle_1. Text)
Bfname=left (bfname, len (bfname) - 2)
//d: \ SLGZ directory for the database files, the TMP. Db for temporary database file
Mysql="RESTORE the DATABASE 'd: \ SLGZ \ TMP db' FROM '" + bfname +"' "
The execute immediate: Mysql USING SQLCA;
If the sqlca. Sqlcode<> 0 then
Messagebox (" message ", "data recovery failed! 'the information! , OK!
Return
End the if
Disconnect;//disconnect from the database
Gzname='d: \ SLGZ \ gz db//contains the path of the database file
SetFileAttributes (gzname, SXZ)//remove the read-only attribute
TMP=filedelete (' d: \ SLGZ \ gz db)//remove to restore the database before
If TMP=false then
Messagebox (" message ", 'backup failed! 'the information! , OK!
Return
End the if
//will be a temporary database replication on the current database file
Bfname="d: \ SLGZ \ TMP db"
Gzname="d: \ SLGZ \ gz db"
KB=filecopy (bfname gzname, true)
If KB=1 then
Messagebox (" message ", "database recovery success! nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull