Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > BOOK: Beginning VB.NET Databases
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 18th, 2008, 03:59 PM
Authorized User
Points: 222, Level: 4
Points: 222, Level: 4 Points: 222, Level: 4 Points: 222, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2007
Location: Phoenix, AZ, USA.
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"
  StackTrace:
       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
        Next

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.


Thanks


Tom


Thomas G Magaro
__________________
Thomas G Magaro
Reply With Quote
  #2 (permalink)  
Old February 19th, 2008, 06:29 AM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Location: Fuquay Varina, NC, USA.
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

Tom,

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.

Thearon
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:17 PM.


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