拿到一个access的来电归属数据库,由于数据庞大,冗余过多,所以需要筛选处理。现在用的电脑是新电脑,也没有配置过APACHE之类的东西,如果要写php去处理过程,还需要先安装些软件,个人比较懒,再加上处理的东西比较少,于是最后选择用VB直接处理。
先制作简单的Form,添加2个按钮,一个用来查询记录个数,一个用来执行非查询类的命令。
然后输入以下代码:
Private Conn As New ADODB.Connection Private Sub Command1_Click() Dim ConnectionString As String Set Conn = CreateObject("ADODB.Connection") ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Persist Security Info = False;Data Source =" & "d:\Chromedownloads\TelNumber\TelNumber.mdb" Conn.Open ConnectionString Dim rs As New ADODB.Recordset sql = Text1.Text rs.Open sql, Conn, 3, 3 If rs.RecordCount = 0 Then Label1.Caption = "没有记录!" Else Label1.Caption = rs.RecordCount Conn.Close End If End Sub Private Sub Command2_Click() Dim ConnectionString As String Set Conn = CreateObject("ADODB.Connection") ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Persist Security Info = False;Data Source =" & "d:\Chromedownloads\TelNumber\TelNumber.mdb" Conn.Open ConnectionString Dim rs As New ADODB.Recordset sql = Text1.Text rs.Open sql, Conn, 3, 3 Conn.Close Label1.Caption = "执行完毕!" End Sub
文章评分1次,平均分5.0:★★★★★
网站的知识很全面哦···
呵呵 不懂 啊
VB+Access经典中的经典啊。。。
是啊,刚开始数据库那会,都这样的组合。