Hi,
I'm using Linq in Vb.net 2012
but I'm getting an error as " 'query' is not declared. It may be inaccessible due to its protection level"
how to solve this issue
Imports System.Windows
Imports System.Data
Imports System.Data.SqlClient
Imports System.Linq
Imports System.Collections.Generic
'======================================================================================================
Dim parent As DataTable = dset.Tables("magenmst")
Dim child As DataTable = dset.Tables("magengrp")
dim query = _
From P In parent.AsEnumerable, c In child.AsEnumerable _
Where P.Field(Of)("agcode") = c.Field(Of )("aggrpcd") _
Select P,c;
Dim view As DataView = query.AsDataView()
'======================================================================================================


VulpesRank #55 · 29.2K reputationPosted May 16, 2013, 3:01 AM EDT
Also, I'd have thought that you'll need to insert the appropriate types after 'Of' and remove the semi-colon at the end of the 'query' declaration to get it to compile.
Manoj Patel29 reputationPosted May 16, 2013, 3:47 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 16, 2013, 4:29 AM EDT
The type following 'Of' should of course be the type of the "agcode" and "aggrpcd" columns in the datatables.
System.Data.DataSetExtensions.dll is part of the .NET framework but it's not included in your projects by default. You therefore have to add a reference to it manually.
abhishek goletar11 reputationPosted Jul 30, 2013, 6:53 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 30, 2013, 8:30 AM EDT
Try like this
Regards,
Iftikar