Object Reference Error

dgorka

Well-known member
Joined
Dec 27, 2006
Messages
88
Programming Experience
5-10
So, the following code that I'm posting, was written on my coworkers PC, and is currently in production. On his PC it works fine, as well as in production. We copied the solution to my PC and now it errors whenever I run it. I get an "Object reference not set to an instance of an object." error. The line that errors is in bold. Basically, the only idea we have is that there could be some sort of computer settings that are different between our machines that could be screwing it up. Does anyone know any that would or a way to fix this problem? We're both stumped. Thanks in advance.

PrivateFunction loadTiffList() AsBoolean
Try
da.SelectCommand.CommandText = "Our Select Command"

da.Fill(ds, "tiffs")
If ds.Tables(0).Rows.Count = 0 Then
ReturnFalse
Else
ReturnTrue
EndIf
Catch ex As Exception
ThrowNew Exception("Error during loadTiffList(): " & ex.Message & vbCrLf & vbCrLf & ex.StackTrace & vbCrLf & vbCrLf)
EndTry
EndFunction
 
We figured out the problem, and let me tell you, we're stupid. Basically, I set the select command back how I originally had it:

Dim qry AsNew SqlCommand("Our Select Command")

Then did this:

da.SelectCommand = qry

This is how I had it originally. Although, looking at an older version that he had, we found one difference that we didn't notice before(we were looking at them side by side for about 5 - 10 minutes). We needed to add the connection to our select command. So it should have, and now does, look like this:

Dim qry AsNew SqlCommand("Our Select Command", conn)

So now it works. Thank you to any who looked at this. It is appreciated.
 
youre using .NET 2.0; howcome you are using dataadapters and untyped datatables, with db-access code thrown into the form?
 
Back
Top