Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

All I want to do is put data into a grid. Here is my code:

Sub BindData()
   Dim strConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\intranet\databases\open_en.mdb"
   Dim objConn As New OleDb.OleDbConnection(strConnString)

   Dim strSQL As String = "SELECT  * FROM InsChange"
   Dim objCommand As New OleDb.OleDbCommand(strSQL, objConn)

   Dim objDA As New OleDb.OleDbDataAdapter
   objDA.SelectCommand = objCommand

   Dim objDS As New DataSet
   objDA.Fill(objDS)
   objConn.Close()
 
   grdRecs.DataSource = objDS
   grdRecs.DataBind()
 End Sub

I keep getting "Object reference not set to an instance of an object"

Any help would be appreciated.

Posted

The page builds with no errors. The error occurs when I try to preview the page in a browser window.

Here is the stack trace:

NullReferenceException: Object reference not set to an instance of an object.]

webforms.oe_test.BindData() in J:\WebForms\oe\oe_test.aspx.vb:50

webforms.oe_test.Page_Load(Object sender, EventArgs e) in J:\WebForms\oe\oe_test.aspx.vb:32

System.Web.UI.Control.OnLoad(EventArgs e) +67

System.Web.UI.Control.LoadRecursive() +35

System.Web.UI.Page.ProcessRequestMain() +750

 

Line 50 is

grdRecs.DataSource = objDS

I checked my query and, in the access database, it pulls the data in correctly but it looks like the dataset is null if I am reading it right.

Posted

Well, this is really bizarre. I started by commenting all the code out and adding it back a line at a time, changing nothing and now it works!

*argh*

thanks for your help though. I just wish I knew why it works now.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...