// public_IP_STRING = Trim(Text_0.Text)
// public_SQLOLEDB_STRING = "Provider=SQLOLEDB.1;Password=" & public_PASSWORD & _
// ";Persist Security Info=True;User ID=" & public_USERNAME & _
// ";Initial Catalog=****;Data Source= " & _
// public_IP_STRING & ",1433"
Public Function F_insert_Ver(string1 As Variant, ip_string As Variant) As String
On Error Resume Next
F_insert_Ver = ""
If string1 <> "" And ip_string <> "" Then
Dim select_string, insert_string, st, mm
select_string = "select ver_sig from ut_sud_ver where ver_number = ‘" & string1 & "‘"
Dim db As Connection
Set db = New Connection
db.CursorLocation = adUseClient
db.Open public_SQLOLEDB_STRING
Set rs = New Recordset
rs.Open select_string, db, adOpenStatic, adLockOptimistic
mm = Val(rs.RecordCount)
If mm <> "" Then
If mm > 0 Then
update_string = "update ut_sud_ver set ver_sig=‘0‘ where ver_sig=‘1‘"
db.Execute update_string
update_string = "update ut_sud_ver set ver_sig=‘1‘ where ver_number=‘" & string1 & "‘"
db.Execute update_string
F_insert_Ver = "2"
Else
update_string = "update ut_sud_ver set ver_sig=‘0‘ where ver_sig=‘1‘"
db.Execute update_string
insert_string = "insert ut_sud_ver(ver_number,ver_sig) select ‘" & string1 & "‘,‘1‘"
db.Execute insert_string
st = my_sql.F_get_field(public_SQLOLEDB_STRING, "ut_sud_ver", "ver_number", "ver_number", string1)
If st <> "" Then
F_insert_Ver = "1"
Else
F_insert_Ver = "0"
End If
End If
End If
rs.Close
End If
End Function
VB 数据库操作实例:写入软件版本号(版本控制代码实现)