LINQ To XML Query Returning No Results?
Jul 20, 2011
I'm doing some XLINQ in VB for work. I basically need to pull some values from a small chunk of XML as listed here:
<?xml version="1.0" encoding="utf-8"?>
<Fields>
<typeQtyRadioButtonList>1</typeQtyRadioButtonList>
<cmbQtyCheck>Reject</cmbQtyCheck>
[code]....
... Leaving out the implementation of the For Each loop....So I have stuck a break point on the for each and the collection has no elements in it.
View 1 Replies
ADVERTISEMENT
Mar 5, 2011
I have a query using LINQ-to-SQL. It queries an underlying database table Rooms. It uses Where conditions to narrow down the results, namely:
Gender.Current Occupancy < Max Occupancy Available Flag is Checked I know this should return results but it keeps returning an empty set.Code is below
[code]...
UPDATE: I've verified that the issue is with the statement where sh.is_available = 1, which doesn't make sense since this is a bit field.
View 3 Replies
Mar 3, 2010
So, I'm not really sure if I have this setup properly or not. This is my first attempt at utilizing LINQ and I am trying to return data directly from an XML file.Here is my XML structure:
<folder_list>
<folder lbl="_localhost" abs="C:\_localhostapache2triadhtdocs" unc="C:\_localhostapache2triadhtdocs" tag="default" />
<folder lbl="Programming" abs="D:\_prog" unc="D:\_prog" tag="default" />
<folder lbl="Anime" abs="D:Anime" unc="D:Anime" tag="default" />
[Code]...
View 9 Replies
Mar 11, 2010
Im currently working on an n-layer application that does alot of database work.90% of all database queries are updates, and inserts and I want to be able to view the results of my query in the presentation layer.I was thinking of creating a QueryResult class that has a few properties like QuerySuccessful (boolean), Message (string) - holds success or error message, and optional field to hold any additional data that may need to be passed back to the presentation layer.So I guess my question is, am I going about this the correct way by creating a QueryResult class, and passing that back up through the layers to my PL?
View 2 Replies
Jan 22, 2010
I have the follow Linq query that is in a web application that was converted from .NET 1.1 to 3.5:
dim objListOfFilteredDataRows = from datarows as datarow in objDataSet.tables(0).rows _
where datarows("SomeColumn") = SomeValue
I have the exact same query in an application that was created using .NET 3.5 and the query returns an IEnumerable. However the query in the converted application is returning:
{Name = "WhereEnumerableIterator`1" FullName = "System.Linq.Enumerable+WhereEnumerableIterator`1[[System.Data.DataRow, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"}
**Edit: When I highlight the expression, the intellisense says that it doesn't know the type of objListOfFilteredDataRows and assumes its a type of "Object". Why is the type not infered in the converted 1.1 application but is infered in the "native" 3.5?**
What am I missing here? How do I convert the "WhereEnumeratorIterator`1 to an IEnumerable?
View 5 Replies
Apr 28, 2011
Just a quick question about LINQ, I want to use a value from the returned dataset to lookup a value and return this. The line I am struggling with is .ViewingNotes = NewViewing(pt.ProspectId).GetViewings().Columns(7).ToString(). Is this possible?
With BusinessLayerObjectManager.Context
Return (From p As [Property] In .PropertySet
Join pt As Prospect In .Prospects On pt.Property.propertyID Equals p.propertyID
[code].....
View 1 Replies
Sep 11, 2009
I have used linq quite abit but was just wondering how to append the results of two IEnumerable(of X) together into one IEnumerable(of X)
View 4 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
Mar 3, 2009
I have the following code:
Dim db As New linqclassesDataContext
Dim categories = (From c In db.faq_cats)
NewFaqDropDownCategory.DataSource = categories
[code]....
View 3 Replies
Feb 3, 2011
In my application, I have a search query textbox (txtSearch) that works well with one-word queries with the following LINQ:[code]So how would I make the above query more generic (ie: able to handle any number of words in a query)?I should note that the object being queried is a List of strings pulled from an Access database. As it stands, this application only queries the database once and I'd like to keep it that way if possible.
View 3 Replies
May 29, 2009
The only way I know of is awkward:
'check for empty return
Dim count As Integer = (From s In myEntity.employee Where employeeID = myEmployeeIDVariable).Count
'If there is a record, then process
[code]....
View 2 Replies
Dec 7, 2010
I have a VB .Net linq query that I want to return values from two tables. I currently have this:
Dim query = (From c In db.Client _
Join u In db.Users _
On u.UserID Equals c.UserID _
Where (c.ClientID = 1)
Select c, u).ToList
query (System.Collections.Generic.List(Of )) returns several rows as expected each item containing a c and a u.
How do I iterate through the queries collection?
View 1 Replies
Apr 9, 2011
I have the following LINQ-to-Entities query:[code]This will give me all the resident assignments for the current year/term. Then I have this LINQ-to-Entities query:[code]This will give me all the rooms. I want to iterate through the assignments and based on what room is assigned update the occupancy in reset_occupancy. I'm not 100% sure how to accomplish this. Here is my pseudo code of what I want to accomplish:[code]
View 1 Replies
Dec 15, 2009
I have the following LINQ-to-Entities query:
' Get all the residency assignments that match the term/year.
Dim assignments = From p In dbContext.Residents _
Where p.semester = term _
[code].....
View 1 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
Nov 17, 2010
We are noticing this occurs BOTH in javascript and in VB.net 2.0. So basically both in server side and client side code. Basically if you run this equation 975328 - 153279.43 you get the following answer 822048.57000000007. However, if you run 975328 - 153279.4, 975328 - 153279.433, or 975328 - 153279.5 everything is returned correctly. WHY the system calcuates the 975328 - 153279.43 with an answer with 11 decimal places? Not to mention adding the 7 in the 11th decimal place, thus making the equation answer incorrect.Of course I know I can trim, set the answer to appropiate decimal places, etc., etc.the above is proven by just entering the equation into the immidiate window, thus ellimnating varibables such as object types, etc., etc.
View 3 Replies
May 18, 2010
I have been having an issue with returning records from a SQLServer database where the date the record was created is between 2 user specified dates. When I populate the DataGridView with the results, they are incorrect and do not follow any recognisable pattern.
For example, if I specify the dates 05/05/2010 and 12/05/2010 I get the attached data in the DataGridView.
Code:
Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
'Clear the DataGridView
[Code].....
View 3 Replies
Mar 5, 2011
I am pulling a date value from my database:
Dim qfresho = From p In dbConfig.Configs _
Where p.Description = "FROD" _
Select p.dateValue
Dim qfreshc = From p In dbConfig.Configs _
Where p.Description = "FRCD" _
Select p.dateValue
Then comparing these date values to the current date:
[Code] .....
But for some reason its always returning the Else condition - even though the values in the database should make the query true. I'm guessing for some reason its not pulling the results as a date?
View 3 Replies
Apr 5, 2011
I have a GridView which is showing results and from which I am deleting a result using the auto-created delete link. My code behind to remove the row and associated info. is:
Private Sub GridView1_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
' The deletion of the individual row is automatically handled by the GridView.
Dim dbDelete As New pbu_housingEntities
' Remove individual from the bed.
[Code] .....
It seems that it is not able to grab the row that is being deleted, so it is always giving me a "Object reference not set to an instance of an object" error.
View 1 Replies
May 7, 2012
like an Interop user control (VB.NET) to return and to accept multiple values from a get/set call. I assumed a user defined type (UDT), would be the correct way but I keep getting a "Variable uses an Automation type not supported in Visual Basic¯ from the VB6 compile. How is passing multiple values between an interop control and the VB6 application done?VB.NET (Interop) code, a control with a .NET ListView
Structure Employee
Dim Firstname As String
Dim Lastname As String
[code].....
View 2 Replies
Mar 30, 2009
I have a problem which I have tried to solve in several ways, and by searching the Internet for various terms, searching through books and Visual Basic instructional videos, but none have yielded the correct results. My goal is as follows:
1. Create a Database listing job names, job numbers, and a link to the file about the job.
2. Create a form with 2 text boxes, a search button, a box to display results, and a preview panel.
The two above steps have been completed. The following is where I get stuck
3. I want to search for either the job name, and/or the job number, have VB search through the database and return the results in the results box.
4. On clicking on one of the results in the result box, the preview panel will show a preview of the file.
Notes:
i) The files being linked top are Microsoft Excel files.
ii) The box I have used for the results currently is a listbox, though I've no idea if this is the correct choice for what I want to do.
iii) The database I created is an *.xml database created in Visual Basic. I am a fair beginner to VB, learning as I go, but I'm stumped as to how to achieve this so any pointers on how to achieve points 3 or 4
View 2 Replies
Nov 25, 2011
I have been taking a class in Visual Basic and am currently working on my final project which I am having some trouble with. I am using Visual Basic 2010 express The project is to create an application that will store data in a text file, specifically, Last Name, First Name, Customer Number, Address, City, State, ZIP Code, Telephone Number, Account Balance, and Date of Last Payment. I have gotten everything done except the ability to search the file by Last Name or Customer Number. I have no idea how to go about this? I was thinking of ways to use indexof or Readline to be able to search the data, but I'm not familiar enough with the code to come up with a good solution. Below is a picture of how my form looks..As you can see, I'm currently using 2 separate forms to get the data from the user. Here is the code for Form1 which is the "Customer Accounts" form in the picture.
Imports System.IO
Public Class Form1
Public customerFile As StreamWriter ' Object variable
Public customerFile1 As StreamReader ' Object variable
Public strFile As String
[Code]...
There isn't enough room to post the code for my secondary form, but you get the idea. I would like to be able to enter a search term in the textbox on the bottom right of the form, and either search the data as its displayed in the listbox, or search the actual file? I was thinking that the results would be displayed in a messagebox?
View 3 Replies
Mar 11, 2010
how to take a query that returns a single row of data and load that data into textbox controls.I know about ExecuteScalar but it is only good for a single column of data from the query.
View 2 Replies
May 23, 2011
I am working with a method using LINQ to XML to return a string.This is the XML
<data name="lnkViewResultResource1.Text" xml:space="preserve">
<value>View results</value>
</data>
[code].....
View 3 Replies
Feb 23, 2011
I have a Search web reference (from a Search Server 2010 express install) in a vb.net application that is utilizing the QueryService Class to search a production Sharepoint foundation 2010 site.At a previous point in time, we had created a proof of concept on an entirely test system that has since been turfed. From my recollection on this test system when documents were uploaded as a specific site content type (that inherits from document) and metadata was provided, we could search for specific metadata by making managed properties for each, and search results would be returned as documents (with the isdocument flag set to true). Viewing the document then became simple, as we could simply use the filename and path to display the stored file.Now we are developing a production system and we have encountered a new behavior, where these results now are returned as aspx results such as
[URL]
This of course makes it terribly difficult to locate and view the document, we can extract the Title which will then give us the name of the file with no extension, but that hardly helps, as the FileExtension data is aspx, not the documents file extension, so we don't have a full filename. We could display the page returned as a result, but would much prefer the document itself.
I've made a test document library, with just bare bones setup, (not using the site content type, or site columns) and uploaded some documents on the same site, and they are returned in the same fashion, so I don't believe the document library, or content type are the issue.
With a fairly limited understanding of both Sharepoint and Search Server, I don't know if this is a setup issue with the search service itself, with the site configuration, or with the querypacket I am sending. We also have a third party application (Knowledgelake) installed on the server that ties into sharepoint which could have changed configuration somewhere as well?
I don't think the query packet has changed since it was working in the proof of concept, other than the custom data column names. I will provide it here in case there is something glaringly obvious to an external reader.
<QueryPacket xmlns='urn:Microsoft.Search.Query.Document'>"
<Query>
<SupportedFormats>
<Format>urn:Microsoft.Search.Response</Format>
[code]....
View 1 Replies
Jul 14, 2011
given this function:
Public Function Search(ByVal StartIndex As Integer, _
ByVal MaxResults As Integer, _
ByVal AccountNumber As String, _
ByVal LastName As String, _
[Code]....
instead of what I expected:
Select count(*) from remitline where lastname = "smith"
What am I doing wrong building up the where clause? I'm using Castle ActiveRecord 2.1
View 1 Replies
Aug 6, 2009
if there is that much of a performance gain in running a LINQ stored procedure versus a LINQ query?
View 1 Replies
Sep 14, 2010
I have to join two main tables, and I need to filter the results by elements in an ASP.NET web form. These filters are created on the fly so I have to use a lot of where extensions to filter the query. I want to execute the query with as optimized SQL as possible.
I am first doing a simple join between TW_Sites and TW_Investigators. Then there are two sub-tables that are involved. TW_InvestigatorToArea and TW_InvestigatorToDisease. While most of the where clauses are working fine, I have found a performance issue that won't be an issue right now, but will be an issue as the table gets bigger.
The arrays DiseaseCategories and DiseaseAreas would be the results of a CheckBoxList result.
Protected Sub LoadResults()
'Get Dictionary of Filters
Dim FilterDictionary As OrderedDictionary = Session.Item("InvestigatorFilterDictionary")
' Initialize LinqToSql
[code]....
View 2 Replies
Mar 15, 2012
I am messed up with the below query[code]...
but when i run the query in my project the reader in not reading correctly...even if values are present is returns false and if values are not there then it returns true.
View 10 Replies
Apr 25, 2009
I'm trying to query a remote machine and get the cpu percentage similar to task manager.. I have the following code:
Code:
im wmiK As New WMI
Private objMgmt As ManagementObject
[code].....
View 10 Replies