GetValue Method?

J

jtnpham

Hi, I am programming in vb.net for an asp.net web page. I have the
following code:

sqlStr = "SELECT dbo_shoporder.shopordernumber, authtable.authno FROM
authTable INNER JOIN dbo_ShopOrder ON authtable.shoporderno =
dbo_shoporder.shopordernumber WHERE dbo_shoporder.workcenterid ='" &
Convert.ToString(txtWcSearch.Text) & "' AND authTable.workcenterid =
'" & Convert.ToString(txtWcSearch.Text) & "';"

Dim dataAdapter3 As New OleDbDataAdapter(sqlStr, connStr)
Dim dt3 As New Data.DataTable
dataAdapter3.Fill(dt3)
gvData.DataSource.Equals(dt3)
dataAdapter3.Dispose()

Now, when I run it I get this exception:

"Object reference not set to an instance of an object."

And then when I put this in the help search it returned something with
the GetValue Method (obj,obj). Can someone explain this to me? I
tried looking at it in MSDN but it wasn't a very good example and did
not explain much to me.

Basically, my SELECT statement is grabbing shop order numbers from
dbo_shopOrders and authorization numbers from authTable where the work
center equals whatever is typed in the textbox: txtWcSearch.text.

Any help would be great!

Thanks! =)
 
M

Mr. Arnold

Hi, I am programming in vb.net for an asp.net web page. I have the
following code:

sqlStr = "SELECT dbo_shoporder.shopordernumber, authtable.authno FROM
authTable INNER JOIN dbo_ShopOrder ON authtable.shoporderno =
dbo_shoporder.shopordernumber WHERE dbo_shoporder.workcenterid ='" &
Convert.ToString(txtWcSearch.Text) & "' AND authTable.workcenterid =
'" & Convert.ToString(txtWcSearch.Text) & "';"

Dim dataAdapter3 As New OleDbDataAdapter(sqlStr, connStr)
Dim dt3 As New Data.DataTable
dataAdapter3.Fill(dt3)
gvData.DataSource.Equals(dt3)
dataAdapter3.Dispose()

Now, when I run it I get this exception:

"Object reference not set to an instance of an object."

Well the message above means that an object as not been instanced.

In you were doing it in code yourself, it would be like this.

dim myobj as new jtnpham

If you did dim myobj as jtnpham, then it's not an object, because the *new*
keyword in not there.

If you tried to access myobj without the *new* being used, then you're going
to get the "object not set to instance of an object.

In other words, something needs to be an *object* before it can be
referenced.

I don't use datatables and dataAdapters, and maybe, that dt3 is returning no
data/null and is not and object, because the SQL statement is not bringing
back data or something has failed, and no object is being returned.

And maybe, you could actually see what's wrong if you have a try/catch block
around the code, so that you could break in the Exception in debug mode and
see the Innertext messages of the Exception to pin point what is wrong.

If you're not using a try/catch around code such as the code above, then
it's recommended that you use try/catch around the code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top