3个回答
展开全部
如果你一定要VB搞,给你部分代码
Private conn0 As New ADODB.Connection
Private ConnString As String
Private SQL As String
Private rs0 As New ADODB.Recordset
Private Sub Command1_Click()
Dim i As String
Dim pc As String
SQL = "Select * From 表名"
ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" + App.Path & "\QQ.mdb" + ";Persist Security Info=False" + ";" & _
"Jet OLEDB:Database Password=False"
If conn0.State <> 1 Then
conn0.Open (ConnString)
End If
rs0.Open SQL, conn0, adOpenKeyset, adLockPessimistic
ReDim ac(rs0.RecordCount) As String
Do While Not rs0.EOF
If rs0.Fields("字段") <> pc Then
ac(i) = rs0.Fields("字段")
pc = rs0.Fields("字段")
i = i + 1
rs0.MoveNext
end if
Loop
Set rs0 = Nothing
Set conn0 = Nothing
Private conn0 As New ADODB.Connection
Private ConnString As String
Private SQL As String
Private rs0 As New ADODB.Recordset
Private Sub Command1_Click()
Dim i As String
Dim pc As String
SQL = "Select * From 表名"
ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" + App.Path & "\QQ.mdb" + ";Persist Security Info=False" + ";" & _
"Jet OLEDB:Database Password=False"
If conn0.State <> 1 Then
conn0.Open (ConnString)
End If
rs0.Open SQL, conn0, adOpenKeyset, adLockPessimistic
ReDim ac(rs0.RecordCount) As String
Do While Not rs0.EOF
If rs0.Fields("字段") <> pc Then
ac(i) = rs0.Fields("字段")
pc = rs0.Fields("字段")
i = i + 1
rs0.MoveNext
end if
Loop
Set rs0 = Nothing
Set conn0 = Nothing
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
干嘛在VB里面搞,完全可以用SQL语句实现。
1、用SQL求和,select sum(需要的列)名 from 表
2、用SQL查询出不重复的字段,select distinct 列名 from 表
1、用SQL求和,select sum(需要的列)名 from 表
2、用SQL查询出不重复的字段,select distinct 列名 from 表
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询