标签:按键精灵 ide static 定义数据 nstat 修改 adl function xxxx
‘--------------------------------------------------------------------------//user_login.cls -->user_login.dll
//Plugin.user_login.F_user
//Plugin.user_login.F_login
//Plugin.user_login.F_select
//Plugin.user_login.F_insert
//Plugin.user_login.F_update 为自定义数据库操作自定义插件
//sqloledb_string = "Provider=SQLOLEDB.1;Password=xxxxxxxx;Persist Security Info=True;User ID=sa;Initial Catalog=Mydbase;Data Source=WIN-2008"
Public Function F_login(sqloledb_string As Variant, select_from As Variant, select_user As Variant, select_password As Variant, String1 As Variant, String2 As Variant) As String
If String1 = "" Or String2 = "" Then
F_login = 0
Else
Dim db As Connection
Set db = New Connection
db.CursorLocation = adUseClient
db.Open sqloledb_string
Set rs = New Recordset
select_string = "select " & select_user & "," & select_password & " from " & select_from & " where " & select_user & " =‘" & String1 & "‘"
rs.Open select_string, db, adOpenStatic, adLockOptimistic
Dim i As String
For t = 0 To Val(rs.RecordCount) - 1
password = Trim(rs.Fields(select_password).Value)
rs.MoveNext
Next t
If password = String2 Then
F_login = 1
Else
F_login = 0
End If
rs.Close
End If
End Function
‘查询数据
Public Function F_select(sqloledb_string As Variant, select_from As Variant, select_id As Variant, select_field As Variant, String_id As Variant) As String
F_select = ""
If select_id <> "" And select_field <> "" Then
Dim db As Connection
Set db = New Connection
db.CursorLocation = adUseClient
db.Open sqloledb_string
Set rs = New Recordset
select_string = "select " & select_field & " from " & select_from & " where " & select_id & " =‘" & String_id & "‘"
rs.Open select_string, db, adOpenStatic, adLockOptimistic
mm = Val(rs.RecordCount)
If mm <> "" Then
String2 = ""
For t = 0 To Val(rs.RecordCount) - 1
String2 = Trim(rs.Fields(select_field).Value) & "|" & String2
rs.MoveNext
Next t
If Val(rs.RecordCount) > 0 Then
F_select = String2
Else
F_select = "0"
End If
End If
rs.Close
End If
End Function
‘写入数据
Public Function F_update(sqloledb_string As Variant, select_from As Variant, select_id As Variant, update_field As Variant, String_id As Variant, String2 As Variant) As String
F_update = ""
If String_id <> "" And String2 <> "" Then
Dim db As Connection
Set db = New Connection
db.CursorLocation = adUseClient
db.Open sqloledb_string
Set rs = New Recordset
select_string = "select " & select_id & " from " & select_from & " where " & select_id & " =‘" & String_id & "‘"
rs.Open select_string, db, adOpenStatic, adLockOptimistic
Dim mm
mm = Val(rs.RecordCount)
If mm <> "" Then
If mm > 0 Then
update_string = "update " & select_from & " set " & update_field & "= ‘" & String2 & "‘ where " & select_id & "=‘" & String_id & "‘ "
‘ MsgBox (update_string)
db.Execute update_string
F_update = "1"
Else
F_update = "0"
End If
End If
rs.Close
End If
End Function
‘加入数据
Public Function F_insert(sqloledb_string As Variant, select_from As Variant, insert_field As Variant, String1 As Variant) As String
F_insert = ""
If insert_field <> "" And String1 <> "" Then
Dim db As Connection
Set db = New Connection
db.CursorLocation = adUseClient
db.Open sqloledb_string
Set rs = New Recordset
select_string = "select * from " & select_from & " where " & insert_field & " =‘" & String1 & "‘"
rs.Open select_string, db, adOpenStatic, adLockOptimistic
Dim mm
mm = Val(rs.RecordCount)
‘ MsgBox mm
If mm <> "" Then
If mm = 0 Then
insert_string = "insert " & select_from & " ( " & insert_field & " ) select ‘" & String1 & "‘"
‘ MsgBox (insert_string)
db.Execute insert_string
F_insert = "1"
Else
F_insert = "0"
End If
End If
rs.Close
End If
End Function
标签:按键精灵 ide static 定义数据 nstat 修改 adl function xxxx
原文地址:https://blog.51cto.com/12815848/2528331