I have the following code in my application. When it is executed it brings out a null value at times, where i am sure there should be a value returned. I have checked by running the sql statement in the database and it returns the correct value. What could be wrong with my code? [Code]
I have some code which gets child items for a menu via the GetChildren function which takes a list of menuData: Dim builtMenu As New List(Of MenuData)(_rawData.FindAll(Function(item) item.GroupingID = 0))
For Each menuData As MenuData In builtMenu If menuData.Children IsNot Nothing Then menuData.Children.AddRange(GetChildren(menuData)) End If Next
If I check if menudata.children isnot nothing, it always is nothing because the GetChildren function is yet to run (providing the child items, which do exist). If I remove this check and just have this code:
Dim builtMenu As New List(Of MenuData)(_rawData.FindAll(Function(item) item.GroupingID = 0))
For Each menuData As MenuData In builtMenu menuData.Children.AddRange(GetChildren(menuData)) Next
Then I am presented with a Object reference not set to an instance of an object error on menuData.Children.AddRange(GetChildren(menuData))
I have a WPF application that uses a third-party library to perform a specific task; this library, in one of its methods, executes the statement Assembly.GetEntryAssembly(). If I run the WPF application on debug (by running a .Net exe for testing) the library works properly and Assembly.GetEntryAssembly() returns a reference to the assembly of the executable, but in production I have a different situation that causes me some problems.
Rather interesting bit on this one, I have all the code where it should be working but whenever it hits parse1 it returns the file as null. [code] I probably just need a fresh pair of eyes because I'm not seeing where this is glitching (...or if it's just my computer in this case.)Rather annoying at this point, tried break points and following the execution to catch the error but no such luck.
I have some VB.NET code that creates a TransactionScope instance:
LoggingUtility.LogDebug("UpdateCallTable", "SatComCallDataImporter", "About to associate call data with contracts") Using ts = New TransactionScope() LoggingUtility.LogDebug("UpdateCallTable", "SatComCallDataImporter", "Getting all unimported SatCom calls")
My application is throwing an exception on the call to the creation of a new TransactionScope, with "Object reference not set to an instance of an object.". The exception isn't thrown on my development machine or my test machine; only on the customers production machine, and I have no idea why. I've placed debug lines immediately before and after this line so I'm positive it is this line causing the problem.
A have used TransactionScopes throughout the application and this is the only place throwing the exception on the client machine."About to associate call data with contracts" gets written to the log and the next log entry is the "Object reference not set to an instance of an object".
Code works fine if I move it out of a transaction.I've been struggling with this for 4 days now and have got no closer.
i hav two openfilefialogs(1 and 2). So i also have a listbox. the files opened with the openfiledialogs will be added to the listbox. and when i need to open the files i need to see if they are from which openfiledialog. so
it is like this.
Path.GetDirectoryName(OpenFileDialog1.FileName) & "" & Form3.ListBox1.SelectedItem.ToString 'if this returns a null then go to this Path.GetDirectoryName(OpenFileDialog2.FileName) & "" & Form3.ListBox1.SelectedItem.ToString
Is their a more elegant way to assign a space to a value, if a database call returns null for a data set column? I am doing the following check which is pretty tedious:
If (ds.Tables("employee").Rows(0).Item("txtNamePrefix").IsDBNull(0)) Then txtNamePrefix.Text = "" Else txtNamePrefix.Text = ds.Tables("employee").Rows(0).Item("txtNamePrefix") End If
I have a DataGridView connected to a DataSet. I want to allow the user to update and insert new records on the RowLeave and CellLeave events. The Update method works: Me.ExpensesTableAdapter.Update(Me.DataSet1.Expenses)
I am basically trying to access the CLSID portion of the registry... some CLSIDs are working, some arent...
Here is my code: Dim regkey As RegistryKey regkey = Registry.ClassesRoot.OpenSubKey("CLSID" & location & "InprocServer32", False) 'Just Returns null when im looking for a certain CLSID Dim SubKeyvalues() As String = regkey.GetValueNames() Dim subkeyvalue As String subkeyvalue = regkey.GetValue(SubKeyvalues(0))
I'm trying to get data with the methods below and I get null response and can't figure out why. I'm just trying out a different way of using a wcf service from silverlight and I don't understand something that I should.[code]...
The employee object will stay null. If I put a break into the service call and follow through the code it finds the correct record from the database and the return statement shows an object with the correct data but still the employee object in silverlight side will remain null.
By my logic, this should only assign .length to index IF the length of strItem is longer than 0. This check is there in case the listbox is empty, or the user has not selected an item. However, everytime I go through this code without an item selected I get:
I have a several form elements that I am dynamically creating with javascript when a user changes a number value in a textbox, by filling the innerHTML of a div like so:
Then, in the aspx.vb code behind, when the user clicks the Save button, I run through a series of Requests to try and add the values that are in these form elements to a SQL string:
Dim DFTestValue1 As String DFTestValue1 = Request("textbox" & c.ToString)
where c is a loop counter to the # of textboxes created (the input value mentioned above that triggers the create) The problem here is that this code works in Internet Explorer but not in Firefox or Chrome. The Request() value returns null and nothing is saved. I hope I've explained this well enough.
I have a vb.net app that I can read a .xls file into a dataset or loop through as oledbdatareader and it gives the same result.Some of the rows have all nulls when I loop through them but if I open the same file in Microsoft Excel I can see that row fine.[code]From the info above the first two SKU values would come through fine but when I get to the 3rd row it would show a null.Is it possible that it kind of inherits the first rows type and since the 3rd row isn't all numeric if nulls it? [code]
I have a select statement which was returning the required values but when I changed the OS date from English(US) to English(UK), it now returns null. I believe the problem is concerned with date since in the query am selecting values where the date from the database is the same as the date in a combobox but I don't know what else I can do. It almost looks like the dates in the combox and in the database are not the same and yet the date in the combobox is actually retrieved from the database and has been returning values fine until I changed the system date format.Here's my select command:
cmd4.CommandText = _ "SELECT sum(brought_qtty), recieved_qtty from brought_coffee, centre_weigh where brought_date=#" & _ dtComb.Text.Trim & "#" & _[code].......
I tied a text box to dataset using the following code
tbAddr.DataBindings.Add("Text", dsCust, "SYS_CUSTOMER.Address"); gridview to same dataset using dgvNames.DataSource = customerBindingSource - this is in property box. customerBindingSource.DataSource = dsCust.Tables["SYS_CUSTOMER"];
i make changes in text box tbAddr update_click () in this method i use the following code
I have created a strongly typed dataset in the VS 2005 Dataset Designer. There are two tables that relates to each other in a one to many relationship: Claim and ClaimDetail. The designer automatically creates a function GetClaimDetailRows which returns all ClaimDetailRows for a ClaimRow. Why is this Array's length always 0? Because ClaimDetail contains more than 40 Million rows, i did'nt fill it before i call GetClaimDetailRows but had configured it's selectcommand that it takes a parameter idData to fill only the related records. But that seems not to work because the ClaimDetail-Datatable is empty.
The automatically generated function in the ClaimRow-Class which returns all related ClaimDetailRows: Public Function GetClaimDetailRows() As ClaimDetailRow() If (Me.Table.ChildRelations("Claim_ClaimDetail") Is Nothing) Then Return New ClaimDetailRow(-1) {} Else Return CType(MyBase.GetChildRows(Me.Table.ChildRelations("Claim_ClaimDetail")),ClaimDetailRow()) End If End Function
When debugging I see that it jumps into the else block but returns 0 rows. Do I have to fill the Claimdetail-Datatable first(ClearBeforeFill=True) for each Claim? But then I don't need to use this function anymore. I now fill the Datatable(ClearBeforeFill=True)before i call the Child-function and it works. But I don't understand why it could not throw an exception(optionally) when I try to acess a child-relation without having that datatable being filled(at least with 0 rows). Instead of that it returns 0 rows what can be correct or incorrect and is difficult to detect.
Public Sub checkemail() sqlcheckemail = "select Email from WEBUSER where Email='" + TBEmail.Text + "'" Dim dscheckemail As New DataSet
[Code]....
if u see the one that i've commented is the one i already googled at tested...so now if the email address exist in the db..everything works wonderful..but if it doesn't exist the code should process the one that does not satisfy the first if statement...but now i'm getting the result as "There is something" eventhough the email does not exist in the db...
I am making use of a 3rd party dll and am encountering some strange behavior in VB, which doesn't occur in C# Perhaps someone can explain what is going on. Anyhow, I am making use of a method in this 3rd party library which accepts an array parameter ByRef. The end result is the variable should remain null after the method call, but it is returning initialized for some reason.
I keep getting the error "Object reference not set to an instance of an Object" on the below highlighted line of code and I understand why. It's because I'm checking for something that hasn't even been initialized yet. My question is, what's the best way to check a DataTables row count without getting that error before refilling it?
If Not ds.Tables("tblNotes").Rows(0).IsNull(0) Then ds.Tables("tblNotes").Rows.Clear() End If adp.Fill(ds, "tblNotes")
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")
In a WinForms app (VS2008 / .Net Framework 3.5) I bind data from SQL Server to controls. If there's a null value e.g. an employee has no middle name (allowed by business rules), when I browse that record at runtime an exception is thrown. So I code: If Not (row("middle_name") Is DbNull.Value then txtMiddleName.DataBindings.Add(New Binding("Text", row, "middle_name)). Say someone adds a middle name to this record, because the control had no databindings the dataset.HasChanges property is false and update stored proc doesn't run. I guess I could handle this like this: If txtMiddleName.Databindings.Count = 0 AndAlso txtMiddleName.Text <> "" Then row("middle_name") = txtMiddleName.Text. I guess I would have to do something similar to handle a value changing from not null to null.
Private _PurchaseDelivery as PurchaseDelivery Protected Overrides Sub InsertItem(ByVal index As Integer, ByVal item As PurchaseDeliveryItem)
[Code]....
Which is inside a class which overrides a custom list base. The code is occassionaly throwing an unhandled exception, System.NullReferenceException, on this line when used in production:
If _PurchaseDelivery IsNot Nothing AndAlso _PurchaseDelivery.DefaultSKUBinID.HasValue Then
DeafultSKUBinID is declared as an Integer? (Nullable Int) in the PurchaseDelivery class. I cannot see what might be causing this error, why would this be returning an error?