|
-
Sep 21st, 2006, 01:44 PM
#1
Thread Starter
Member
[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.
-
Sep 21st, 2006, 02:19 PM
#2
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.
-
Sep 21st, 2006, 02:24 PM
#3
Thread Starter
Member
Re: [02/03] Can't put together two strings, runtime error.
 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.
-
Sep 21st, 2006, 02:57 PM
#4
Frenzied Member
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.
-
Sep 21st, 2006, 03:06 PM
#5
Re: [02/03] Can't put together two strings, runtime error.
 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").
-
Sep 21st, 2006, 04:25 PM
#6
Thread Starter
Member
Re: [02/03] Can't put together two strings, runtime error.
 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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|