1,216
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Private Declare Function SendMessagebyString Lib _
"user32" Alias "SendMessageA" (ByVal hWND As Long, _
ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As String) As Long
Private Const LB_FINDSTRINGEXACT = &H1A2
Private Sub Command1_Click()
Dim cn As ADODB.Connection, rs As ADODB.Recordset
Dim strLine As String, n As Long
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\test\test.mdb;"
rs.Open "select * from table8", cn, adOpenKeyset, adLockOptimistic
List1.Clear
Do Until rs.EOF
strLine = rs!A & rs!B & rs!C
n = SendMessagebyString(List1.hWND, LB_FINDSTRINGEXACT, -1, strLine)
If n = -1 Then
List1.AddItem strLine
rs!No = List1.NewIndex + 1
Else
rs!No = n + 1
End If
rs.Update
rs.MoveNext
Loop
End Sub
select ta.* ,tb.NO
from
table as ta,
(select a,b,c row_number() over(partition by null order by null) as NO from table group by a,b,c) as tb
where ta.a=tb.a and ta.b=tb.b and ta.c=tb.c