[RESOLVED] [02/03] Can't put together two strings, runtime error.
This is the offending piece of code, the boldened part is where the error occurs.
VB Code:
Dim sqlQuery As String = "INSERT INTO longdescs (bug_id, " & _
"bug_when, " & _
"thetext, " & _
"who) " & _
"VALUES ("
[b]sqlQuery &= data.Tables("ProblemTable").Rows(0).item(0).ToString & ", '"[/b]
This is the error that I'm getting while running it.
Code:
System.NullReferenceException: Object reference not set to an instance of an object.
I used New in order to create a new instance of the DataSet object so I don't understand the warning message about the object reference being not set.
Re: [02/03] Can't put together two strings, runtime error.
Either:
1) the dataset "data" has no table "ProblemTable" or
2) "ProblemTable" has no data in it
Thus, when you try to refer to it, you trigger an a null reference exception.
Re: [02/03] Can't put together two strings, runtime error.
Quote:
Originally Posted by stanav
Either:
1) the dataset "data" has no table "ProblemTable" or
2) "ProblemTable" has no data in it
Thus, when you try to refer to it, you trigger an a null reference exception.
There is such table (I'm looking at the Access DB right now) and the dataset does have values in it (I checked beforehand by taking the length of it, which was greater than 0.)
The weird thing is that when I replaced the string "ProblemTable" with 0, it worked without a hitch.
Re: [02/03] Can't put together two strings, runtime error.
It looks like you are missing a parenthese.
You open it here:
"VALUES ("
but you don't close it.
Re: [02/03] Can't put together two strings, runtime error.
Quote:
Originally Posted by YourSurrogateGod
There is such table (I'm looking at the Access DB right now) and the dataset does have values in it (I checked beforehand by taking the length of it, which was greater than 0.)
The weird thing is that when I replaced the string "ProblemTable" with 0, it worked without a hitch.
You can do a quick check by running a loop to display all table names of in data.Tables(). Table(0) might not be the same Table("ProblemTable").
Re: [02/03] Can't put together two strings, runtime error.
Quote:
Originally Posted by mpdeglau
It looks like you are missing a parenthese.
You open it here:
"VALUES ("
but you don't close it.
I close it later on in the code.