我試圖使用linq查詢從vb中的數據庫中查詢值,但得到了一些錯誤。如何在vb.net中使用linq查詢數據表中的單個值
這裏是我的代碼:
For Each cl In clients
Dim cn As DataTable
cn = getClients() #datatable with two columns, client code (cln_idck) and client name (cln_name)
Dim clientname As String
clientname = From cntable In cn Where cntable.Item("cln_idck") = cl Select (cntable.Item("cln_name")).ToString()
#do something
Next
我只是試圖抓住客戶名稱,並使用客戶端代碼搜索放入字符串變量CLIENTNAME。上面的代碼給了我一個錯誤。
「範圍變量名無法比擬的成員的名字‘這是爲什麼不工作對象’類」
任何想法?
感謝您的幫助!
拉斐爾
更新:
客戶端(字符串)列表,具有客戶端代碼
Dim clients As New List(Of String)
clients.Add("Cln1")
clients.Add("Cln2") #etc.
什麼是_clients_? – Steve
嗨,對不起,不說明。客戶端是一個包含客戶端代碼的列表(字符串)。 –
可能重複的[爲什麼我不能在VB中項目ToString()?](http://stackoverflow.com/questions/4646724/why-cant-i-project-tostring-in-vb) – DavidG