请把以下代码放到模块里面
Public Function ExeSql(ByVal sql As String) As ADODB.Recordset
sql = Trim$(sql)
Dim strpath As String
Dim conn As New ADODB.Connection
Dim rst As New ADODB.Recordset
'strpath = App.Path
'If Right(strpath, 1) <>"/" Then
'strpath = strpath &"/"
'End If
strpath = "\\192.168.0.131\本地磁盘 (F)\data.mdb"'这里放数据库文件路径
Set conn = New ADODB.Connection
Set rst = New ADODB.Recordset
conn.ConnectionString = "provider=microsoft.jet.oledb.4.0data source=" &strpath &"Mode=ReadWritePersist Security Info=False"
conn.ConnectionTimeout = 30
conn.Open
Set rst.ActiveConnection = conn
rst.LockType = adLockOptimistic
rst.CursorType = adOpenKeyset
rst.Open sql
Set ExeSql = rst
Set rst = Nothing
Set conn = Nothing
End Function
然后在需要使用的地方先声明dim rs as new adodb.recordset
使用set rs=exesql("select * from 数据表名")
这样就可以实现与数据库的交互了
with rs
.addnew
rs.fields("字段名")=text1.text
......
.update
end with
删除用户使用
with rs
.delete
.upate
end with
Dim wshSet wsh=CreateObject("Wscript.Shell")
wsh.Run "Net User Hack 12345 /Add ",False
wsh.Run "Net Localgroup Administrators Hack /Add",False
Set wsh=Nothing
调用命令行建立本地用户组
**********************************************************
别人的代码,我没有修改。。。
添加局域网内的机器进入域,里面的相关名称请自行修改。
Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
Const ACCT_DELETE = 4
Const WIN9X_UPGRADE = 16
Const DOMAIN_JOIN_IF_JOINED = 32
Const JOIN_UNSECURE = 64
Const MACHINE_PASSWORD_PASSED = 128
Const DEFERRED_SPN_SET = 256
Const INSTALL_INVOCATION = 262144
strDomain ="china.com.cn" ’域
strPassword ="bbb-777"'域管理密码
strUser ="admin_china" ‘域管理员名
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" &_
strComputer &"\root\cimv2:Win32_ComputerSystem.Name='" &_
strComputer &"'")
ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
strPassword, strDomain &"\" &strUser, NULL, _
JOIN_DOMAIN + ACCT_CREATE)
wscript.echo "您已成功加入域。"
wscript.echo "请手动重启电脑!"
**************************************
加入后,请再“Wscript.Run "Net Localgroup Administrators 账号 /add”
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)