Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
object reference is not set to an instance of an object in vb.net
i am getting error

VB
Dim SC6Report As SC6Reports = _entities.SC6Reports.Where(Function(x) x.IDSC6Reports = SC6ReportID).FirstOrDefault
bcSC6Report.DataSource = SC6Report
_idSC6Reports = SC6Report.IDSC6Reports///////////[getting error]</big>
FillRemedialActions(SC6ReportID)
btnSave.btnOperation.Enabled = True
btnRemActionSet.enabledAdd = True
btnRemActionSet.enabledDelete = True
btnRemActionSet.enabledModify = True
Posted
Comments
Ranjan.D 24-Jan-14 11:53am    
it looks like SC6Report is Nothing. Just put a break point and verify whether you are getting SC6Report instance or not ?
Member 10424744 24-Jan-14 12:01pm    
its showing null , what can i do now ?
Ranjan.D 24-Jan-14 12:03pm    
_entities.SC6Reports might not have records for SC6ReportID so the .FirstOrDefault will return Nothing. You will have to make sure you have records for SC6ReportID in _entities.SC6Reports.
Member 10424744 24-Jan-14 12:05pm    
yes i have records
can i take out firstORdefault?
Ranjan.D 24-Jan-14 12:10pm    
No you should not remove, Also your code should handle when there's no instance. See there's a check on IDSC6Reports = SC6ReportID. I think it's not getting satisfied for the SC6ReportID.

1 solution

Try debugging your source code to figure out where the error occurs.
As the error suggests, an object is null.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900