VB更新時間戳字段

2021-06-16 09:06:58 字數 1208 閱讀 1751

option explicit

private sub command1_click()

dim objcnn as adodb.connection

dim strtmp as string

dim objrst as new adodb.recordset

dim strsql as string

set objcnn = new adodb.connection

with objcnn

.connectionstring = "provider=sqloledb;data source=192.168.8.249;database=pa;uid=sa;pwd=kicpassword"

.open

end with

'ftimestamp 為timestamp型別的字段

objrst.open "select top 1 ftimestamp from m_batch01", objcnn, adopenstatic, adlockreadonly

if not objrst.eof then

'先取得查詢到的時間戳

strtmp = timestamptostring(objrst.fields("ftimestamp"))

msgbox strtmp

'進行更新,注意更新條件裡加了時間戳(主要用來處理併發使用,防止更新的時候記錄被其他使用者修改)

strsql = "update m_batch01 set i***porttok='y' where batchid=1882 and ftimestamp=" & strtmp

objcnn.execute strsql

msgbox "ok"

end if

end sub

'轉換函式

private function timestamptostring(rscol as adodb.field) as string

dim buffer as string

dim i as integer

buffer = "0x"

for i = 1 to 8

buffer = buffer & right("00" & hex(ascb(midb(rscol, i, 1))), 2)

next i

timestamptostring = buffer

end function

mysql更新時間戳 Mysql中時間戳自動更新

mysql時間戳字段更新 timestamp是mysql中的時間戳字段,這個字段可以支援自動新增和更新。1.概述 在我們設計表的時候,考慮將行資料的建立時間和最後更新時間記錄下來是很好的實踐。尤其是可能需要做資料同步或者對資料新鮮度有要求的表。舉些應用場景,更新距上次更新超過2小時的行資料,或者是將...

模型自動載入時間戳字段

模型一般預設有個兩個時間字段。乙個是新增時間,乙個是修改時間 我這個是基於tpshop該的 這是model.php 呼叫updatetime 如圖下意思就是 如果模型定義這個update time欄位 並且新增的時候會檢測要新增的陣列是否有update time 這個字段。if this autow...

關於kettle時間戳增量更新

之前看到的一篇文章kettle實現資料實時增量同步,這位大佬提出了時間戳增量回滾同步的一種方式,我是根據這篇文章之上進行探索的。但是遇到了一些問題,這裡進行一下記錄 只能同步往前 day這段時間內的刪除操作,因為回滾了一段時間 day,作者也宣告了這點 也只能同步往前 day這段時間內的刪除操作,為...