Reputation: 13
I am new in Linq. The error(conversion from string "SYMBOL" to type integer is not valid) comes in the line : ' r("SYMBOL") = q!SYMBOL.ToString'. Please help
Dim tblBhavNSEFO As DataTable = gbl_dsBhavNSEFO.Tables(0)
Dim tblSource As New DataTable
tblSource.Columns.Add("SYMBOL", GetType(String))
Dim tblsymbols As DataTable = (From s In tblBhavNSEFO _
Where s!INSTRUMENT = strCondition _
Order By s!SYMBOL Ascending _
Select s).CopyToDataTable
Dim filter = From f In tblsymbols _
Select f!SYMBOL Distinct
If filter.Count > 0 Then
For Each q In filter
Dim r = tblSource.NewRow()
r("SYMBOL") = q!SYMBOL.ToString
tblSource.Rows.Add(r)
Next
Upvotes: 0
Views: 410
Reputation: 172200
The loop variable q
already contains the symbol (you projected on f!SYMBOL
in the definition of filter
). Thus, adding !SYMBOL
to q
is not necessary.
Upvotes: 1