使用sql无源连接,须先点 工程 菜单 选择 引用 然后勾选Microsoft ActiveX Data Objects 2.8 Library和Microsoft ActiveX Data Objects Recordset 2.8 Library
Dim db As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
Dim c As Integer
Dim d As Integer
Dim b As String
Private Sub Form_Load()
db.Open "Provider=sqlOLEDB.1;Password=123;Persist Security Info=True;User ID=sa;Initial
Catalog=DATABASENAME;Data Source=192.172.0.2"
End Sub
Private Sub Timer1_Timer()
c = c + 1
If c Mod 60 = 0 Then
d = d + 1
rs.Open "update mes_sn set fnextterminalid=1098 where fworkorderno='m3112039405' and fnextterminalid=1097 and
fcurrentterminalid=1099",db
b = Str(d)
Label1.Caption = "已经执行第" + b + "次"
End If
End Sub
原文链接:https://www.f2er.com/vb/260162.html