Null Result In LINQ?
Apr 11, 2012
I'm having trouble with a null result, when I compare the query it said I cant it give the following error "sequence contains no elements"
Dim existe = (
p In abc.Ventadetalles
Where p.idarticulo = txtArticulo.Text
[code].....
View 3 Replies
ADVERTISEMENT
Jul 15, 2011
How to check whether a column is null i use the following code but I got this error "Input string was not in a correct format."
[Code]....
View 2 Replies
Dec 22, 2009
I have a sql query which is returning null value below is the section the iID is null.Once debugger reaches this it goes to exception as its result is NULL. How to control debugger from going to the exception.
[Code]...
View 2 Replies
Aug 5, 2011
I get a warning message that reads " Variable 'cust' is used before it has been assigned a value. A null reference exception could result at run time.", but it occurs in my vb file "Northwind.vb with the following code:
Public Class Northwind
Private cust As BizObjects1.Customer
Private Sub frmCustomer_Load( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
[Code] .....
View 2 Replies
Jan 29, 2012
Warnings: Variable 'targetPath' is used before it has been assigned a value. A null reference exception could result at runtime.
View 39 Replies
Jul 4, 2011
CustomerStreamToRead' is used before it has been assigned a value. A null reference exception could result at runtime.I get that warning once I commented out the streamreader line listed below. The warning shows for the line loading settings(z). The app runs but I don't like warnings in my error list.
Code:
Public Sub LoadSettings()
Dim Z As Integer
Dim CustomerStreamToRead As StreamReader
[code]....
View 5 Replies
Apr 28, 2011
Background: I wrote code that will output all the currently logged in User's Active Directory group names. I want the group name (ex: Acomp_user_BIG) via IdentityReference.Translate instead of the current user's SID's (ex: S-1-5-32-544) returned via IdentityReference.Value.
Here is code that I used:
Public ReadOnly Property Groups As IdentityReferenceCollection
Get
Dim irc As IdentityReferenceCollection
[Code].....
View 3 Replies
Feb 20, 2012
Due to this error I am getting a default date 1/1/1900. Variable 'dr' and 'dr1' is used before it has been assigned a value. Here's the code:-
[Code]...
View 10 Replies
Jun 12, 2011
Variable 'loNode' is used before it has been assigned a value. A null reference exception could result at runtime.
why I am getting this error?
Imports System.Xml
Module Module1
Sub Main()
Dim doc As New XmlDocument
[code].....
View 2 Replies
Sep 19, 2011
Is it possible to add some hours to linq date result ? something like this:
[Code]...
View 3 Replies
Aug 3, 2011
i have found alot of sh*** right now. But not the things that im looking for.
I need to export a LINQ query (or the Datasource of my DataGridview)
to an existing Excel Spreadsheet. Lets Say after Cell A25
I have a Windows Form application using LINQ for the Databindings.
View 1 Replies
Jun 16, 2011
I have something that I want to do and what looks very simple, but I cannot get it to work. I want to build a function that gets as input a xdocument and some other strings. It should have a return that contains a filtered part of the xdocument in a way that I can use it as input for a new Linq function. This is what I mean:
Private Function fncGetFilteredDecendantsOfNode(ByVal xdocDoc As XDocument, _
[Code]...
View 2 Replies
Dec 2, 2010
I'm trying to serialize a LINQ result in this way:
Private Sub btnXML_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnXML.Click
Try
[Code].....
View 2 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
May 28, 2010
I've long since built a way around this, but it still keeps bugging me... it doesnt help that my grasp of dynamic LINQ queries is still shakey.
For the example:
Parent has fields (ParentKey, ParentField)
Child has fields (ChildKey, ParentKey, ChildField)
Pet has fields (PetKey, ChildKey, PetField)
[Code].....
The above Join call doesnt work. I sort of understand why it doesnt work, but hopefully it'll show you how I tried to accomplish this task.
After all this was done I would have appended a Select to finish the job.
I tried it with the PredicateBuilder with little success. I might not know how to use it right but it felt like it wasnt gonna handle the joining.
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
Apr 6, 2010
I have a page with a form on it and needs a range of dates. Thus I've placed a number of textboxes on the page into which users can type dates. When the user clicks the save button I want to trigger a LINQ update to the SQL Server...all the rows already exist, so I'm just updating existing data.
For example, lets say my table looks like this:
Column Names: Description dateValue
Column Values:
Birthdate 1/1/1990
Anniversary 1/10/1992
Death 1/1/1993
I want to do something like this:
hupdate.Description("Birthdate").dateValue = TextBox1.Text
hupdate.Description("Anniversary").dateValue = TextBox2.Text
hupdate.Description("Death").dateValue = TextBox3.Text
hconfig.SubmitChanges()
Is there a way to do this with LINQ?
View 1 Replies
Aug 20, 2010
I have the following query, I'd like to sum the NULL value also. Some TimeSheet don't records in TimeRecord and some tr.TimeIn and tr.TimeOut are NULL.The query select only TimeSheet that has reords in TimeRecord. How I can have it select everything, and sum up the NULL value as well. So, the SUM of NULL will be just zero.
[Code]...
View 1 Replies
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
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
Mar 23, 2009
I have a requirement where I have to add items into a List(Of T) (let's call it Target) from an IEnumerable(Of T) (let's call it Source) using Target.AddRange() in VB.NET.
Target.AddRange(Source.TakeWhie(Function(X, Index) ?))
The ? part is a tricky condition that is something like: As long as the as yet unenumerated count is not equal to what is needed to fill the list to the minimum required then randomly decide if the current item should be taken, otherwise take the item.Somethig like...
Source.Count() - Index = _minimum_required - _curr_count_of_items_taken _
OrElse GetRandomNumberBetween1And100() <= _probability_this_item_is_taken
' _minimum_required and _probability_this_item_is_taken are constants
The confounding part is that _curr_count_of_items_taken needs to be incremented each time the TakeWhile statement is satisfied. How would I go about doing that? I'm also open to a solution that uses any other LINQ methods (Aggregate, Where, etc.) instead of TakeWhile.If all else fails then I will go back to using a good old for-loop =)
View 2 Replies
Jan 9, 2012
I have the code as below:
Dim xdTest As XDocument = XDocument.Load(GetXMLPath())
Dim objResult = From xe In xdTest.Elements("Some Element") _
Where xe.Element("strName").Value = strInput _
Select xe.Element("intValue").Value
objResult.
I cannot access any extension methods for objResult, like .ToList() or .First(). The file imports System.Linq and the project is targeted to .NET 3.5. How do I get the extension methods back?
View 1 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
May 24, 2009
I've got a subquery that returns the most recent value from a child table. In some cases the subquery returns nothing. The query below fails at runtime because the inferred type of MemberPrice is decimal and is not nullable. [code]...
View 4 Replies
Apr 19, 2011
I have a XML xElement like[code]...
In order to get rid of Trick nodes where value is null, I wrote:
myXmlElement.<Play>.<Trick>.Where(Function(m) m.<Trick>.Value = "").Remove()
View 4 Replies
Dec 2, 2011
I'm having trouble figuring out what to do with the bolded part, when there are no nodes to return.If there are no image tags inside the <images> tag, i get an "Object reference is not set to an instance of an object".I have been searching and searching for an answer but can't find one.
Dim orders = From o In xmlLinq.Descendants("order")
Select New With { _
.orderID = o.Attribute("id").Value, _
[code].....
View 2 Replies
Mar 15, 2008
I'm binding a DataGridView to a BindingSource to a LINQ IEnumerable, I found that the BindingSource.Find method throws an exception because .Find isn't implemented in IEnumerable (and the BindingSource just passes the call to it's DataSource). I need to use BindingSource.Find to select/highlight a particular row in the DataGridView.
Is there a feasable way to extend my DataContext to support this behavior w/o breaking anything else? I expected to find the code out there already, but I've searched exaustively with no luck.Without it, I cannot "move" the BindingSource using .Position and that's a pretty common use of the BindingSource I think.
View 1 Replies
Aug 26, 2011
I have a DataSet where I need to filter the collection where one of the date columns is not null.
How do you term this in LINQ?
This is what I have so far but there is a compiler error on the w.CompletedDate field in the Where clause.
Dim completed = From ins In InspectionDataset.Inspection.AsEnumerable _
Where (Function(w) w.CompletedDate IsNot Nothing) _
Order By ins.Field(Of DateTime)("UpdatedDate")
I have also tried it the below way but the compiler will not allow the DBNull comparison.
Dim completed = From ins In Inspection.AsEnumerable _
Where ins.Field(Of DateTime)("CompletedDate") <> DBNull.Value _
Order By ins.Field(Of DateTime)("UpdatedDate")
View 1 Replies