如何将sql数据库的文件备份到本地?
用最简单的步骤备份sql数据库的文件到本地: response.Charset = utf-8 Session.Codepage = 65001 Response.Buffer=true Response.Clear '根据你的情况修改用户名和密码 constr=Provider=SQLOLEDB.1;Persist Security Info=True;User ID=endiva;Password=endi
用最简单的步骤备份sql数据库的文件到本地:
response.Charset = "utf-8"
Session.Codepage = 65001
Response.Buffer=true
Response.Clear
'根据你的情况修改用户名和密码
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"
如果想直接备份并下载,可以加上下边的这部分,就会备份后自动保存。但是弹出的文件是.asp的文件,修改下就OK。
'set fn=server.createobject("adodb.stream")
'fn.mode=3 '读写
'fn.type=1 '数据类型为:adTypeBinary
'fn.open
'fn.LoadFromFile bkfname '将bkfname指定的文件装入对像中
'Response.ContentType="application/octet-stream"
'Response.BinaryWrite fn.read
'fn.close
,