如何将数据库操作封装成控件

myfriendhome 2003-08-18 10:55:55
如何将数据库操作封装成控件。
...全文
29 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
sky125 2003-10-14
  • 打赏
  • 举报
回复
up
hdslah 2003-10-03
  • 打赏
  • 举报
回复
up
hlm750908 2003-09-30
  • 打赏
  • 举报
回复
要ocx干什么?
编一个函数
Public Function chaxun(ByVal sql As String, msgstring As String) As ADODB.Recordset
On Error GoTo ExecuteSQL_Error

Dim cN As ADODB.Connection
Dim rst As ADODB.Recordset
Dim a() As String
Set cN = New ADODB.Connection


Dim str As String
str = App.Path
If Right(str, 1) <> "\" Then
str = str + "\"
End If

cN.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\data\rsgl.mdb;Persist Security Info=False;jet OLEDB:Database password=422127197509080072"
cN.Open


a = Split(sql)

If InStr("insert,delete,updata", Trim(a(0))) Then
cN.Execute sql
Select Case Trim(a(0))
Case "insert"
msgstring = "添加记录"
Case "delete"
msgstring = "删除记录"
Case "updata"
msgstring = "更新记录"
End Select
msgstring = msgstring & "已完成"
Else

Set rst = New ADODB.Recordset
rst.CursorLocation = adUseClient
rst.Open sql, cN, adOpenKeyset, adLockOptimistic

Set chaxun = rst
msgstring = "查询到" & rst.RecordCount & "条记录"
End If

ExecuteSQL_Exit:
Set rst = Nothing
Set cN = Nothing
Exit Function

ExecuteSQL_Error:
msgstring = "查询错误: " & _
err.Description
Resume ExecuteSQL_Exit
End Function













调用
Dim xx As String
Dim yy As String
Dim mrc As ADODB.Recordset
Dim i As Long

xx = "select * from 操作员表"
Set mrc = chaxun(xx, yy)
shadowli995 2003-08-18
  • 打赏
  • 举报
回复
楼上的书生,可以说的详细点吗?
suji2002 2003-08-18
  • 打赏
  • 举报
回复
用ADO呀,将数据实行绑定,在出现的对话框中加一些对数据库实行操作的控件就可以了

6,108

社区成员

发帖
与我相关
我的任务
社区描述
其他数据库开发 数据库报表
社区管理员
  • 数据库报表社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧