lorena Posted September 6, 2006 Posted September 6, 2006 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. Quote
Administrators PlausiblyDamp Posted September 6, 2006 Administrators Posted September 6, 2006 Where do you keep getting the error? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
lorena Posted September 6, 2006 Author Posted September 6, 2006 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. Quote
Administrators PlausiblyDamp Posted September 6, 2006 Administrators Posted September 6, 2006 If you put a breakpoint on that line and run the code what value does the debugger display for objDS and grdRecs? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
lorena Posted September 6, 2006 Author Posted September 6, 2006 I can't run the debugger. I am doing development on a remote server and have never been able to get the debugger to work Quote
Administrators PlausiblyDamp Posted September 6, 2006 Administrators Posted September 6, 2006 In that case check if either of them is nothing and drop a debug message to the page telling you if either of them is nothing. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
lorena Posted September 6, 2006 Author Posted September 6, 2006 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.