Wrox Programmer Forums
BOOK: Beginning VB.NET Databases
This is the forum to discuss the Wrox book Beginning VB.NET Databases by Thearon Willis; ISBN: 9780764568008
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning VB.NET Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 18th, 2008, 03:59 PM
Authorized User
Join Date: Dec 2007
Posts: 48
Thanks: 4
Thanked 0 Times in 0 Posts
Default Object reference not set

I am working on Ch 3 of the book. I have followed the instructions as close as possible, however I'm working with VS 2005. When I run the project, I get the following error:

System.NullReferenceException was unhandled
  Message="Object reference not set to an instance of an object."
  Source="ODBC Data Wizard"
       at ODBC_Data_Wizard.Form1.cboCompanies_SelectedIndexC hanged(Object sender, EventArgs e) in C:\Users\Tom Magaro\AppData\Local\Temporary Projects\ODBC Data Wizard\Form1.vb:line 13
       at ODBC_Data_Wizard.Form1.Form1_Load(Object sender, EventArgs e) in C:\Users\Tom Magaro\AppData\Local\Temporary Projects\ODBC Data Wizard\Form1.vb:line 7
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
       at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.SafeNativeMethods.ShowWindow( HandleRef hWnd, Int32 nCmdShow)
       at System.Windows.Forms.Control.SetVisibleCore(Boolea n value)
       at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Control.set_Visible(Boolean value)
       at System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(ApplicationCo ntext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.Run(String[] commandLine)
       at ODBC_Data_Wizard.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context( Object state)
       at System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

The offending code follows:

For intIndex = 0 To customersDs1.Tables("Customers.csv").Rows.Count - 1
            If customersDs1.Tables("Customers.csv").Rows(intIndex ).Item( _
                "CustomerID") = cboCompanies.SelectedValue Then
                Dim strName As String
                strName = customersDs1.Tables("Customers.csv").Rows(intIndex ).Item( _
                    "First Name") & " " & customersDs1.Tables("Customers.csv").Rows _
                    (intIndex).Item("Last Name")
                txtName.Text = strName
                txtTitle.Text = customersDs1.Tables("Customers.csv").Rows(intIndex ).Item("Job Title")
                txtPhone.Text = customersDs1.Tables("Customers.csv").Rows(intIndex ).Item("Business Phone")
                Exit For
            End If

I have even tried starting from scratch. When I did get the program to run, I forget how, I ended up with no data.

Any insight or suggestion to fix this problem would be appreciated.



Thomas G Magaro
Thomas G Magaro
Old February 19th, 2008, 06:29 AM
Thearon's Avatar
Wrox Author
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts


It sounds like the customersDs1 dataset has not been loaded. You can verify this by setting a breakpoint on the For statement and then hovering your mouse over the customersDs1 dataset in your code. VS will either report it as a dataset or as object reference not set.


Similar Threads
Thread Thread Starter Forum Replies Last Post
object reference not set to instant of an object shahidrasul ASP.NET 2.0 Basics 1 September 5th, 2008 02:01 PM
Object Reference not set to an instance of object srinivas_chakka ASP.NET 1.0 and 1.1 Professional 0 February 8th, 2006 11:56 AM
Getting Error - "Object reference not set to an in peri C# 2 December 24th, 2004 11:20 AM
Object reference not set to an instance... steelman BOOK: ASP.NET Website Programming Problem-Design-Solution 6 May 7th, 2004 02:03 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.