Assign Result (from LINQ To XML Query) To List(Of String)?
Jul 6, 2011
Is it wrong? Please suggest me correct way.
Public Function ReadXML() As List(Of String)
Dim list As New List(Of String)
Dim xmlDoc As XDocument = XDocument.Load("C:\MappingFile.xml")
[code].....
View 1 Replies
ADVERTISEMENT
Apr 24, 2011
How do I assign the query result to a variable.I am using SQLlite. Below is the code for retrieving password from the User Table. I need to compare the given password and the given password.
Dim i As String
Dim p As String
i = txtUserID.Text
[code].....
View 1 Replies
Feb 3, 2012
I am using a path comparison to find any children tags which works well when there is only 1 tag selected. This is my code for when multiples tags are selected but it is not working. Can you point me in the right direction?
Single Tag Selection (working)
Dim tagpath = uxTags.SelectedItem.Text
lnqCases = From i In lnqCases Where i.HelpDeskTagItems.Any(Function(x)
[code]...
View 1 Replies
Oct 28, 2010
I want to declare a variable to hold the query result from LINQ to SQL like to the following:
Dim query As IQueryable(Of Student)
If isNoUserName Then
query = From st In db.Students _
Order By st.AssignedId Ascending _
[code]....
Return query
Error : conversions from 'System.Linq.IQueryable(Of )' to 'System.Linq.IQueryable(Of Student)'.
How do I declare variable "query" to hold both data from "Student" and "User" tables?
View 1 Replies
Nov 16, 2010
Here is the original xml file
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<setup>
<cap>33</cap>
</setup>
[Code]...
View 2 Replies
Dec 5, 2009
I have a set off LINQ queries filtering original datatable (loaded from Excel file) according to user selections in Comboboxes. Then the result is joined with Arraylist to further filter the set. Arraylist is a simple string list from 1 to 5. [Code]
View 3 Replies
Nov 15, 2011
I have a question regarding LINQ 2 SQL and data integration with textbox:I have one textbox and button on my form, one stored procedure and LINQ 2 SQL class file in my project,I want that when I hit button, my store procedure run the SQL query and show me the result in textbox.I am using VB 2008 and Visual Basic for programing.
View 2 Replies
Mar 19, 2010
Is there a VB.NET equivalent to the C# var keyword? I would like to use it to retrieve the result of a LINQ query.
View 4 Replies
May 9, 2012
I want to create a LINQ to entities query getting data(join) out of two tables and bind the result as datasource to a datagridview.
Unfortunately I seem to stumble upon a syntax issue.
Table 1 : dcpricing.tblpricing
Table 2 : dcpropertydetail.tblpropertydetail
Grid: grdpricing
[Code].....
View 5 Replies
Nov 22, 2009
I have a function that works great in C# that I'm converting to VB.Net. I'm having an issue converting the result set to a generic list in VB.net.
The code:
Public Function GetCategories() As List(Of Category)
Dim xmlDoc As XDocument = XDocument.Load("http://my_xml_api_url.com")
Dim categories = (From category In xmlDoc.Descendants("Table") _
Select New Category()).ToList(Of Category)()
Return categories
End Function
The error occurs when convertng the result via .ToList(Of Category)() The error:
Public Function ToList() As System.Collections.Generic.List(Of TSource)' defined in 'System.Linq.Enumerable' is not generic (or has no free type parameters) and so cannot have type arguments.
Category is a simple object I've created, stored in the App_Code directory.
I have the necessary "Imports System.Collections.Generic" reference in the file so I don't see why I can't convert the result set to a generic list.
View 2 Replies
Oct 25, 2010
I managed to do ASP.NET authentication work wih AD. Now, I want to query an OU in AD and display the result either ListView or GridView in ASP.NET page.[code]In the organizational unit (OU) UsersStudents there are following columns:First Name, Last Name, Pre-Windows 2000 Logon Name, Name , Type. I want to query column First Name, Last Name, Pre-Windows 2000 Logon Name in OU UsersStudents and bind the
result to ListView or GridView.
View 3 Replies
Sep 2, 2011
Dim query = From o In myContainer.MyObjects Select o.MyStringProperty Distinct
Dim myProperties As List(Of String) = query.ToList????? 'no way!!!'
"query" type is IEnumerable(Of String)
I tried to use the query directly as a DataSource of a (infragistic) combobox, but it throws me NullReferenceException, so I decided to convert it to a listof strings, to be a more "classical" datasource.
Dim values As List(Of String) = query.AsQueryable().ToList()
does not work either: Value of type 'System.Collections.Generic.List(Of System.Linq.IQueryable(Of String))' cannot be converted to 'System.Collections.Generic.List(Of String)'.
View 3 Replies
Sep 12, 2011
'Read RESX file and returns a List(Of ResXDataNode)[code]...
Provide two separate copies of the node? Or will the List and Linq query still be referencing the same data?
View 2 Replies
Jun 28, 2011
I have this code:
[Code]...
View 3 Replies
May 3, 2012
I have a query that 'selects' object of a type:
Dim l as IList(Of Foo) = (From dataRow As DataRow In table.Select()
Where CStr(dataRow("Column1")) = "A"
Select New Foo(CStr(dataRow("Column1")), _
CStr(dataRow("Column2")))).ToList()
What's happening is that if i set a break-point to the constructor of Foo and step, the constructor is hit and the parameters are loaded with the arguments. However, l has empty Foo objects (the members in every object are Nothing). What could be happening here?
View 1 Replies
Mar 8, 2010
I have got an xml document which looks something like this.
<Root>
<Info>
</Info>
<Info>
[Code]...
How can i write a linqToXML query so that it returns me an IEnumerable containing each child element, in this case all five child elements of , so that i could iterate over them. The order of child elements is not definite, neither is number of times the may appear.
View 1 Replies
Oct 24, 2010
If I use a LINQ query over some type of collection, is there any way to know the initial index of an element of the result?
Purpose: I make a query to set as source of a DataGridView, and on a (button)cellclick event I want to a call a method that needs to reference the collection at the correct index.
View 13 Replies
Dec 15, 2010
I got an object of List<List<string>>I need to bring this into a ist<string>I have no idea how to do this with LINQ.
View 1 Replies
Jun 30, 2011
Could not find this through Google or in SO questions.I have a checkbox listbox on my form. I want to filter my List by the list of selected Ids from that listbox that are checked, in SQL I would have done this like "Where TypeId In (1, 4, 5, 7)"... how do I do that in LINQ?
I feel like I am missing a really obvious answer, but cannot get it.
For argument sake... here is the what I have for sample data:
In Colors (List<of currentColors>)
ID, Name, TypeId
1, Red, 1
2, Blue, 1
3, Green, 2
4, Pink, 3
Selected Types 2 and 3 in CheckboxList: filteredColors
[Code]...
View 1 Replies
May 26, 2012
I am not sending any sensitive or security information in the query string. I am currently using Base64Encoding along with MD5 Hash. I want to shorten my url as far as possible.
[Code]...
View 2 Replies
Apr 5, 2012
GOAL: Bind nested ListViews to LINQ generated iQueryable of anonymous type. I want to use LINQ because you can use GroupBy and bind the nested ListView to the 'it' keyword.
SETUP: I have groups of sets of conditions. Each set of conditions is stored in the BillingCodes table. Each group of BillingCodes is stored in the BillingGroups table.
I have a custom object that stores the ID, Name, and NumCodes for each BillingGroup that the user has chosen.I have a collection of these objects called GroupsList that has a list of the groups that the user has chosen.
Problem 1: I can iterate through GroupsList and grab all the IDs. How do I translate the SQL 'WHERE ID IN(a string of comma delineated IDs)' for LINQ to SQL? Is that the best way to do that?
Problem 2: Once I have the list of BillingGroups I need to iterate through each group. For each group, I need to iterate through the BillingCodes. For each BillingCode I need to generate a WHERE clause that has all of the conditions in the BillingCode. I propose something like so:
for each BillingGroup in BillingGroups
for each BillingCode in BillingGroup.BillingCodes
where1 = "..."
next
next
Problem 3: Here's the part where I don't have a clue. I need to dynamically create a query in LINQ to SQL. Keep in mind that I don't know how many groups there'll be or how many codes are in each group.
There are 2 tables:
**transactions**
transaction_id
patient_id
[code]....
View 1 Replies
May 25, 2010
I have a query that can be summarised in SQL as follows;
Select
S.StockCode
From
StockToCheck As S
[Code]....
Where the S var is a list of strings. This gives the error 'S' is not declared and points to the S in the function call / join (GetPOSStock). So it does not seem possible to do this in Linq, can anyone confirm?
View 1 Replies
Oct 26, 2011
I have these objects:[code]Using LINQ I need to take a List(Of MakeInfo) and a List(Of ModelInfo) and aggregate the StockInfo from ModelInfo into the List(Of MakeInfo).So for each MakeInfo I will have a total count of all stock where MakeInfo.Name = ModelInfo.Make, and also a minimum price.I think it's going to be something like this, but I'm having trouble accessing the nested object and not sure if it's going to be possible with a single query.[code]
View 2 Replies
Dec 7, 2010
I'm using LINQ to SQL to query some data.Here's my Employees table colummns:
-FirstName (or givename i.e. John)
-LastName (has middle name and family name seperated by space i.e. Mac Tenny
Some people have middle name and some don't. Here's some sample data.
-FirstName LastName
John Mac Tenny (with middle name "Mac")
Mike Mika (no middle name)
[code]....
I want to query for people who have their middle or last name started with search criteria. Here's how I search for employees with middle name started with
"joe" :
query = From emp In db.Employees _
Where emp.LastName.StartsWith("joe") _
Select emp
How do I query for employees with family name(last part of the LastName) started with "joe"?
View 2 Replies
Feb 3, 2011
I have the following routine (that works) but which is messy to update owing to the hand-typed strings it uses:
Private Sub ListDefaults()
Dim conn As New SqlConnection( _
"server=bas047AUTODESKVAULT;Database=DWGDetails;Integrated Security=SSPI")
'Dim conn As New SqlConnection( _
[code]....
View 1 Replies
Oct 12, 2009
I've created a small WPF app in VB9 to catalog our sizable DVD collection. This exercise has been more about learn programming than the need to have a movie database app, but I digress.The SQL database I created has a field for "Genre" that does not have an entry for all the movies in our collection. As such, when I run the method that filters the movie listing by "Genre" the compiler throws the "StrongTypingException was unhandled" error stating "The value for column 'Genre' in table 'Movies' is DBNull.".
I now understand where the DBNull problem comes from and have been searching for several hours to find a VB solution that converts the DBNull fields to strings on the fly during the LINQ query. I've found many solutions people have tried but, since I'm quite new to all this, none of them have worked for me. Pasted below is the method that throws the exception.
[Code]...
View 2 Replies
May 20, 2012
Is there a way to convert a string into a linq query? Searching for those words brings up tons of stuff unrelated to what I'm trying to do..For instance, this works, of course...
Dim lstMyQuery = (From item in htMyTable.values where item(0) = "Apple" Select item)
But somehow I want to do this:
Dim strQuery = "From item in htMyTable.values where item(0) = " & CHR(34) & "Apples" & CHR(34) & " Select item"
Dim lstMyQuery = (Somehow run/convert strQuery as a query)
The reason is strQuery will be different each time depending on what the user has selected earlier in the program.R if lstMyQuery is already a collection, is there a way to add to it?
Dim lstMyQuery = (From item in htMyTable.values where item(0) = "Apples" Select item)
(this obviously doesn't work, but it's basically what I want to do...)
lstMyQuery.Add(From item in htMyTable.values where item(0) = "Oranges" Select item)
View 3 Replies
Mar 8, 2011
What I'm trying to do is to write a generic rss reader that I plug in any URL into without worry if the feed has all the common properties. For instance in my example below I'm looking for pubDate, however if no pubDate exists in the xml I'd like to return the current Date. I cannot seem to get the syntax right though.
Dim xmldoc As New XDocument
xmldoc = XDocument.Load(url)
Dim feeds = From feed In xmldoc.Descendants("item") Select New With { _
[code].....
View 2 Replies
Sep 19, 2011
I have a LINQ2Entity problem, I want to get the value, string, from a database, so I select FProducts.Serial_number, and to end the query, I do .ToDictionary. The problem is, it tells me that it doesn't have sufficient parameters, to convert ToDictionary. So I need something like select FProducts.Serial_number, Nothing). ToDictionary. Also FProducts.Serial_number, 0).ToDictionary doesn't work.
Sub GetStatistics(ByVal ProductNumbers As List(Of String), ByRef Passed As Integer, ByRef FailedProducts As List(Of String))
Passed = 0
FailedProducts = Nothing
[Code]...
View 2 Replies
Sep 22, 2009
I know that LINQ queries are deferred and only executed when the query is enumerated, but I'm having trouble figuring out exactly when that happens.Certainly in a For Each loop, the query would be enumerated.What's the rule of thumb to follow? I don't want to accidentally enumerate over my query twice if it's a huge result.
For example, does System.Linq.Enumerable.First enumerate over the whole query? I ask for performance reasons. I want to pass a LINQ result set to an ASP.NET MVC view, and I also want to pass the First element separately. Enumerating over the results twice would be painful.It would be great to turn on some kind of flag that alerts me each time a LINQ query is enumerated. That way I could catch scenarios when I accidentally enumerate twice.
View 3 Replies