對於名爲ALLconn的數組中的每個連接,我想將它與我的sql表進行比較。如果存在,然後添加到我的列表視圖。這裏是我的代碼如下,但它似乎並沒有工作:比較陣列與SQl表
Dim LoginFilter As Object
Dim SelCurrAllSessions As SqlClient.SqlCommand = New SqlClient.SqlCommand("Select * from CurrAllSessions", LFcnn)
SelCurrAllSessions.CommandType = CommandType.Text
LoginFilter = SelCurrAllSessions.ExecuteReader
For Each conn In AllConn
While LoginFilter.Read()
If conn.UserName.ToString() = LoginFilter.Item(0) Then
ListBox1.Items.Add(LoginFilter.Item(0))
End If
End While
Next
數組的類型是什麼?表中的列是什麼?什麼構成「匹配」? – 2013-05-13 21:07:43