Skip to content

Instantly share code, notes, and snippets.

Created August 30, 2014 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/9c2a408bab050f89469d to your computer and use it in GitHub Desktop.
Save anonymous/9c2a408bab050f89469d to your computer and use it in GitHub Desktop.
Sub test()
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim preDayID As Long
Dim preClosePrice As Double
Dim sqlStr As String
cnn.Open "Driver={MySQL ODBC 5.3 Unicode Driver};" & _
"Server=hogehoge;" & _
"Database=hogeDB;" & _
"Uid=hoge;" & _
"Pwd=hage"
strSQL = "SELECT 終値, id, 前日終値 FROM t_db where id between 130100000 and 200000000 order by id"
rst.Open strSQL, cnn, adOpenForwardOnly, adLockPessimistic
Do Until rst.EOF
If rst("id") = preDayID + 1 Then
rst.Update "前日終値", preClosePrice
End If
preDayID = rst("id")
preClosePrice = rst("終値")
rst.MoveNext
Loop
rst.Close
cnn.Close
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment