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