javascript - 使用经典的 ASP / Javascript ADODB 将行从一个 MS Access 数据库表复制到网络服务器上的另一个
问题描述
我们有一个托管在 godaddy 上的数据库,它为一个用经典 ASP 和一些 Javascript 构建的网站提供数据。我们有一个每日脚本,它通过覆盖刷新数据库,即。完全替换而不是增量。
这样做的缺点是,如果网站正在使用中并且数据库被锁定,那么当我们覆盖时,网站就会崩溃。
所以我们正在研究仅插入新/更新修改记录的选项 - 我们无法让下面的代码工作:
解决方案
以下是一些示例代码,需要完善,但可以测试我们正在评估的场景:
<%
'
' Show Date
'
Response.Write ("Date Today :" & Date & "<br/>")
'
' Connect to DB object
'
sConnect = "Driver={Microsoft Access Driver (*.MDB)}; DBQ=" & Server.MapPath("/temp/propertyDB.mdb")
sConnect_tmp = "Driver={Microsoft Access Driver (*.MDB)}; DBQ=" & Server.MapPath("/temp/propertyDB_tmp.mdb")
'
' Create recordset object
'
Set rsProperty = Server.CreateObject("ADODB.Recordset")
Set rsProperty_tmp = Server.CreateObject("ADODB.Recordset")
'
' Compose the SQL statement for the recordset.
'
sSQL = "SELECT * FROM Property ORDER BY txtRefNo"
'
' Open a recordset and move to the first record
'
rsProperty_tmp.Open sSQL, sConnect_tmp, 3
rsProperty_tmp.MoveFirst
Response.write "- The number of records to INSERT into PropertyDB is : [ " & rsProperty_tmp.RecordCount & " ] <br/>"
'
' Open a recordset and move to the first record + show record count
'
rsProperty.Open sSQL, sConnect_tmp, 3
rsProperty.MoveFirst
Response.write "- Total Number of Records before Insert = : [ " & rsProperty.RecordCount & " ] <br/>"
rsProperty.Close
'
' Insert Into SQL
'
sSQL ="INSERT INTO [property] SELECT distinct * FROM " & Server.MapPath("/temp/propertyDB_tmp.mdb") &".property"
rsProperty.Open sSQL,sConnect,3
Response.write "- The number of records in PropertyDB is now: [ " & rsProperty.RecordCount & " ] <br/>"
'
' CLOSE RecordCount
'
rsProperty_tmp.Close
rsProperty.Close
Set sConnect = nothing
set sConnect_tmp = nothing
Response.Write "- Connection & Recordsets CLOSED OK"
%>
推荐阅读
- c++ - 调用 CreateGraphicsPipelineState 时的 E_INVALIDARG
- c# - 自定义 GUID 始终在 object.Equals 上返回 false
- javascript - 在 React 原生应用中应用 Redux
- swift - Xcode 4 没有声音
- magento2 - 获取错误代码 201 CCAvenue 支付网关
- php - 谷歌云语音识别 API (PHP) - 文件编码问题
- r - [R] 中的简单 [SAS] 宏,怎么样?
- hyperledger-fabric - 执行链码时出错:执行事务失败:执行事务时超时
- ios - 如何让导航栏阴影(分隔线)就像应用商店一样?
- sql - 使用 SQL 在 SQL 中查找无效的 XML/SQL 字符