473,388 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

reading error from table - vb.net- using OleDbDataReader

553 512MB
Hi

When i run the program, i get error on the statement inside Do While Loop. The piece of code from my application is:


Expand|Select|Wrap|Line Numbers
  1. Dim selectString As String
  2.         selectString = "Select ContactName, Address from Customers"
  3.  
  4.         Dim cmd As OleDbCommand = New OleDbCommand(selectString, con)
  5.         Dim reader As OleDbDataReader
  6.  
  7.         reader = cmd.ExecuteReader()
  8.  
  9.         Do While reader.Read() = True
  10.             strName = reader("ContactName")
  11.             strAddress = reader("Address")
  12.         Loop
Object reference not set to an instance of an object
Jun 22 '09 #1
1 2033
tlhintoq
3,525 Expert 2GB
Object reference not set to an instance of an object
You need to initialize all your variables to *something* before you use them.
If you look at your variables after the break, Visual Studio will show you which one(s) are null.
Jun 22 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: arshad | last post by:
Hi, I am facing some problems in reading XML file into dataset in vb.net. The XML is having some duplicate tabels. I am getting the error message saying "The same table(imei_details) cannot be...
3
by: timb | last post by:
Hi, I have created a windows service which is responsible for running certain tasks when they are scheduled to run. The service monitors a sql table and runs a task when the task scheduled time...
0
by: Shiraz | last post by:
I am running Red Hat Linux 3.2.3-20 5.0.18-standard with the data directory on a RAID5 filesystem ext3 data is inserted into the CDRS table @ 100000 record/hour and then moved to RATEDCDR I...
3
by: Maxim Vexler | last post by:
Hello I'm looking for reading materials to educate myself on the security measures that should be taken to build a secure web site. What I'm referring to is web sites like the following : 1....
4
by: Amit Maheshwari | last post by:
I need to read text file having data either comma seperated or tab seperated or any custom seperator and convert into a DataSet in C# . I tried Microsoft Text Driver and Microsoft.Jet.OLEDB.4.0...
2
by: Toco | last post by:
Hello. I have app written in C# that we are testing. The executable is shared on our network. The method we are testing is a call to a foxpro table. The call is made to query the table, then...
2
by: Creascripts | last post by:
I'm having some problem with reading an .xml file: <?xml version="1.0" encoding="utf-8"?> <UserInfoListResult xmlns:xsd="http://www.w3.org/2001/XMLSchema"...
6
by: webandwe | last post by:
Hi, My script lets you choose if you want to view table 1 or table 2 in mysql after you selected 1 or 2 from the drop down menu and press submit. The problem is if you run the script for the...
2
ak1dnar
by: ak1dnar | last post by:
Hi all, I am getting this error in my ASP.net App, when reading some records which contains Null values for some of the columns. System.Data.SqlTypes.SqlNullValueException: Data is Null....
4
by: cplusplusquestion | last post by:
I have a binary file like: a bla bla bla bla b 12 23 34 80 38 a bla bla bla bla b 23 45 89 30 99 When I find first character of the line is 'a', I would like to skip reading this line,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.