vb编程搜索access数据为什么显示空白,程序调试没有发生错误

wangjt1981 2017-06-22 07:37:41
vb编程搜索access数据为什么显示空白,程序调试没有发生错误
程序内容如下:
Private Sub Command1_Click()
Dim strSql As String
If Text1.Text <> "" Then
Adodc1.Recordset.Close
If Val(Text1.Text) > 0 Then
strSql = "select * from table1 where num=" & Trim(Text1.Text)
Else
strSql = "select * from table1 where name='" & Trim(Text1.Text) & "'"
End If
Adodc1.CommandType = adCmdText
Adodc1.Recordset.Open strSql
Set DataGrid1.DataSource = Adodc1
Else
Set DataGrid1.DataSource = Nothing
End If
End Sub

问题出在哪里?为什么搜索后插件里显示的是空白的
...全文
561 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2017-06-23
  • 打赏
  • 举报
回复
愤青从来不缺存在感!
舉杯邀明月 2017-06-23
  • 打赏
  • 举报
回复
一个问题发N多个帖子,这种人是不是有点心理变态? 这个版块根本就没什么人气,难道还担心帖子“被淹没”吗!!!
Tiger_Zhao 2017-06-23
  • 打赏
  • 举报
回复
这是体育老师教的编程?
不要直接操作 Adodc1.Recordset,会影响正常的功能!!!
of123 2017-06-23
  • 打赏
  • 举报
回复
Private Sub Command1_Click()

    Dim strSql As String
    If Text1.Text <> "" Then
        If Val(Text1.Text) > 0 Then
            strSql = "select * from table1 where num=" & Trim(Text1.Text)
        Else
            strSql = "select * from table1 where [name]='" & Trim(Text1.Text) & "'"
        End If
        
        Adodc1.CommandType = adCmdText
        Adodc1.RecordSource = strSql
        Set DataGrid1.DataSource = Adodc1
        Adodc1.Refresh
    Else
        Set DataGrid1.DataSource = Nothing
    End If

End Sub

Private Sub Form_Load()
    Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=[你的数据库文件路径和文件名];Persist Security Info=False"
End Sub

1,451

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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