How do I back up files for SQL databases to local?

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.