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
问题出在哪里?为什么搜索后插件里显示的是空白的
程序内容如下:
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
问题出在哪里?为什么搜索后插件里显示的是空白的
解决方案 »
- 从MSFlexGrid控件把数据导入到excel,请问怎么才能让导入到EXCEL里的数字为数字形式??
- 求一个取字符串内容的写法
- 求:informix如何编写SQL,查询一张表中的前10条记录,谢谢!
- MM求助:哪位帮我看看这段循环程序哪有问题?谢谢了!
- 急~!请教-将查询结果追加到指定表问题[在线等]
- vb中如何保存数据,可另外生成表
- 请进~~~~~~~~~~~~~~(急。。。答出者高分相送)
- 请问用什么函数可以实现从十进制转化成二进制????
- 在treeview中如何将trewview与imagelist联系起来????
- 怎么注册控件?(在没有VB的机器上)
- vb 制作服务器和客户端的问题
- vb编程搜索access数据为什么显示空白,程序调试没有发生错误
不要直接操作 Adodc1.Recordset,会影响正常的功能!!!
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 IfEnd SubPrivate Sub Form_Load()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=[你的数据库文件路径和文件名];Persist Security Info=False"
End Sub