Module1.bas
资源名称:jtlc.rar [点击查看]
上传用户:xxdyjx888
上传日期:2022-06-01
资源大小:55k
文件大小:2k
源码类别:
家庭/个人应用
开发平台:
Visual Basic
- Attribute VB_Name = "Module1"
- Public Str_path As String
- Public Cname As String '登陆时传用户名
- Public Cdate1 As String '传日期(收入情况列表)
- Public Cdate2 As String '传日期
- Public AA As Boolean '判断是否选择月份
- 'ADO编程模型连接数据库
- Public Function Connectstring() As String
- 'Dim Str_path As String
- Str_path = App.Path & "" & "databaseMoneyMIS.mdb"
- Connectstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & Str_path & "';Persist Security Info=False"
- End Function
- 'ADO编程模型连接数据库
- Public Function ExeCutesql(ByVal Sql As String, Msgstring As String) As ADODB.Recordset
- Dim Cnn As ADODB.Connection
- Dim Rst As ADODB.Recordset
- Dim Stokens() As String '数组
- ' On Error GoTo executesql_error
- Stokens = Split(Sql) '将sql语句按关键字保存在数组中
- Set Cnn = New ADODB.Connection
- Cnn.Open Connectstring
- If InStr("INSERT,DELETE,UPDATE", UCase$(Stokens(0))) Then
- Cnn.Execute Sql
- Msgstring = Stokens(0) & "查询成功"
- Else
- Set Rst = New ADODB.Recordset
- Rst.Open Trim$(Sql), Cnn, adOpenKeyset, adLockOptimistic '重服务器中提取符合要求的记录集
- Set ExeCutesql = Rst
- Msgstring = "查询到" & Rst.RecordCount & "条记录"
- End If
- executesql_exit:
- Set Rst = Nothing '释放记录集
- Set Cnn = Nothing '释放连接语句
- Exit Function
- executesql_error:
- Msgstring = "查询错误:" & Err.Description
- Resume executesql_exit
- End Function