vb6.0 mysql ado控件_VB6.0里的ADO控件怎么用?

1,首先开启VB6.0时新建数据工程

2,双击窗体在弹出的窗体中追加控件:Command1,Text1,Adodc1,DataGrid1其中DataGrid1是用来显示查询结果,Adodc1用来导航查询,Text1用来输入查询命令,Command1用来执行查询,下面是详细代码Private Sub Command1_Click()On Error GoTo err If Trim(Me.Text1.Text) "" Then If Adodc_Grid(Trim(Me.Text1.Text), Me.Adodc1, Me.DataGrid1) = True Then MsgBox "查询成功" Else '失败 End If Else MsgBox "请输入SQL查询语句" Exit Sub End If Exit Suberr: MsgBox err.DescriptionEnd SubPublic Function Adodc_Grid(Record_source As String, Adodc As Adodc, Grid As DataGrid) As Boolean '自定义的一个函数 On Error GoTo err Dim cnStr As String cnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\student.mdb ;Persist Security Info=False" With Adodc .ConnectionString = cnStr .CommandType = adCmdText .RecordSource = Record_source Set Grid.DataSource = Adodc .RefreshEnd With Adodc_Grid = True Exit Functionerr: Adodc_Grid = FalseEnd Function

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值