太子长琴重生:VB程序问题3?==详细解释代码。

来源:百度文库 编辑:高校问答 时间:2024/04/28 05:59:27
Set con = New ADODB.Connection
Set rs = New ADODB.Recordset
con.CursorLocation = adUseClient
con.Open "Provider=Microsoft.Jet.OLEDB.3.51;
Data Source=" & App.Path & "\dbnew.mdb;Persist Security Info=False"
If (Trim(Cmbcxfs.Text) = "报警日期") Then
sql = "select * from 处警分析 where 报警日期 =#" + Trim(Txtlr.Text) + "#"
ElseIf (Trim(Cmbcxfs.Text) = "全部") Then
sql = "select * from 处警分析"
Else
sql = "select * from 处警分析 where " + Trim(Cmbcxfs.Text) + "='" + Trim(Txtlr.Text)+"'"
End If

Set con = New ADODB.Connection '实例化connection对象,
Set rs = New ADODB.Recordset '实例化recordset记录集对象
con.CursorLocation = adUseClient '设置游标为客户端游标
con.Open "Provider=Microsoft.Jet.OLEDB.3.51;
Data Source=" & App.Path & "\dbnew.mdb;Persist Security Info=False"
'数据库连接语句,是连接的access2000以下的数据库,连接access2000及以上OLEDB应该是用4.0
If (Trim(Cmbcxfs.Text) = "报警日期") Then
'这个判断不用说了吧,根据条件选择执行的sql语句
sql = "select * from 处警分析 where 报警日期 =#" + Trim(Txtlr.Text) + "#"
ElseIf (Trim(Cmbcxfs.Text) = "全部") Then
sql = "select * from 处警分析"
Else
sql = "select * from 处警分析 where " + Trim(Cmbcxfs.Text) + "='" + Trim(Txtlr.Text)+"'"
End If