vb中将数据库中的数据统计出来进行比较
来源:百度知道 编辑:UC知道 时间:2024/05/15 04:11:45
Private Sub Command1_Click()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=D:\ADODC\Daily.mdb"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from Expense"
Adodc1.Refresh
Dim q As Integer
q = Adodc1.Recordset.RecordCount
Command1.Caption = q
End Sub
用SQL
select * from 表名 where "条件="+command1.caption
你把以上用文字表示的代替一下就行了
用ADODB吧,很简单.
在参照里选Microsoft ActiveX Data Objects2.0 Library
Private Sub Form_Load()
Command1.Caption = "101"
End Sub
Private Sub Command1_Click()
Dim Conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim dbstring As String
Dim sql As String
On Error GoTo Command1_err
dbstring = "Driver={Microsoft Access Driver (*.mdb)};UID=;PWD=520;DBQ=D:\XE.mdb" '这里设置你自己的数据库名,用户名和密码
Conn.