首页
文章
文库
登录
|
注册
最新
推荐
热门
主题
关注
收藏
反馈
关注公众号
vb连接sql模块代码
来源
本站原创
佚名
Public
conn As New ADODB.Connection
Public
rs As New ADODB.Recordset
Public
addFlag As Boolean
Public
Function
OpenCn(
ByVal
Cip As
String
) As Boolean
Dim
mag As
String
On
Error
GoTo strerrmag
Set
conn = New ADODB.Connection
conn.ConnectionTimeout = 25
conn.Provider = "sqloledb"
conn.Properties("data source").Value = Cip '服务器的名字
conn.Properties("initial catalog").Value = "zqoa" '库名
'conn.Properties("integrated security").Value = "SSPI" '登陆类型
conn.Properties("user id").Value = "sa"
conn.Properties("password").Value = "sa"
conn.Open
OpenCn =
True
addFlag =
True
Exit
Function
strerrmag:
mag = "Data can't connect"
Call
MsgBox
(mag, vbOKOnly, "
Error
:Data connect")
addFlag =
False
Exit
Function
End
Function
Public
Sub
cloCn()
On
Error
Resume
Next
If
conn.State <> adStateClosed
Then
conn.Close
Set
conn =
Nothing
End
Sub
Public
Function
openRs(
ByVal
strsql As
String
) As Boolean '连接数据库记录集
Dim
mag As
String
Dim
rpy As Boolean
On
Error
GoTo strerrmag
Set
rs = New ADODB.Recordset
If
addFlag =
False
Then
rpy =
True
With rs
.ActiveConnection = conn
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open strsql
End
With
addFlag =
True
openRs =
True
End
'
Exit
Function
strerrmag:
mag = "data
not
connect"
Call
MsgBox
(mag, vbOKOnly, "
error
:connect")
openRs =
False
End
'
Exit
Function
End
Function
Public
Sub
cloRs()
On
Error
Resume
Next
If
rs.State <> adStateClosed
Then
rs.Clone
Set
rs =
Nothing
End
Sub
关联文档
DeepSeek 搞钱指令库
T GDWJ 016 公立医院全面预算管理工作指南
人工智能技术发展与应用实践
DeepSeek行业应用案例集解锁
2025AI大模型产业市场前景及投资研究报告
大家都在看
一文读懂:模型上下文协议(MCP)
AI产品经理如何搭建AI业务架构:从基础到应用的三层架构设计
智能BI平台架构的全景解析与应用场景
大模型是怎么被训练出来的?
渠道分析从入门到精通
全面解读DeepSeek蒸馏技术:模型蒸馏和数据蒸馏
一文分享 ChatBI 实践经验
深度学习五大模型:CNN、Transformer、BERT、RNN、GAN解析
推荐文档
有赞数据库运维实践
非财务人员财务管理
非欧美地区企业出海信息安全与隐私保护
2015年好孩子战略与构架设计
腾讯智慧出行车联网持续交付之路
OPPO DevOps核心实践