Use the simplest steps to back up the SQL database files to the Local:
Response. Charset = "Utf-8"
Session.CodePage = 65001
Response.buffer=true
Response.Clear
' Modify user name and password according to your situation
Constr= "Provider=SQLOLEDB.1; Persist Security info=true; User Id=endiva; Password=endiva;data source=211.160.78.6 "
Set Conn=server.createobject ("Adodb.connection")
Conn.Open Constr
Bkfname=server.mappath Format_time (Now (), 5) & "Database.bak")
sqlstr= "Backup Database Fang to disk= ' +bkfname+" ' with Init '
Conn.execute Sqlstr
Conn.close
Response. Write "Database [Fang] is backup success!
"
Response. Write "click Download"
If you want to back up and download directly, you can add this section below, and it will be automatically saved after the backup. But the file that pops up is. asp's file, modify the OK.
' Set Fn=server.createobject (' ADODB.stream ')
' Fn.mode=3 ' reading and writing
The ' fn.type=1 ' data type is: adTypeBinary
' Fn.open
' FN. LoadFromFile bkfname ' Loads the files specified by bkfname into the image
' Response.contenttype= ' Application/octet-stream '
' Response.BinaryWrite Fn.read
' Fn.close