Results 1 to 3 of 3

Thread: Error: Object reference not set to an instance of an object

  1. #1

    Thread Starter
    Lively Member Flustor's Avatar
    Join Date
    Sep 2001
    Location
    A small hole in Birmingham
    Posts
    76

    Error: Object reference not set to an instance of an object

    Hi All,

    Anyone know why is is failing with the error "Object reference not set to an instance of an object"?

    I know it's failing at the line indicated...

    VB Code:
    1. sSql = "Select CUSTOMERCODE, CUSTOMERNAME, CUSTOMERADD1, CUSTOMERADD2, CUSTOMERADD3, CUSTOMERADD4, CUSTOMERPOSTCODE, CUSTOMERPRICECODE from PU_CUSTOMERDETAILS"
    2.  
    3. rsCustomerData.Open(sSql, m_dbconn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, -1)
    4.  
    5. 'Loop through all customer records
    6. If rsCustomerData.EOF = False Then
    7.     rsCustomerData.MoveFirst()
    8.  
    9.     'Set up the progressbar...
    10.     lProgressBarCount = 0
    11.     MainForm.ProgressBar1.Minimum = 1
    12.    
    13.     'Error on this line (with the rsCustomerData.RecordCount bit)
    14.     MainForm.ProgressBar1.Maximum = rsCustomerData.RecordCount
    15.  
    16.  
    17.     '...blah blah blah

    By the way, this code runs fine in the Dev environment but not when compiled and installed on the client machine.
    My Spidey senses are tingling!

  2. #2
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Re: Error: Object reference not set to an instance of an object

    is it rsCustomerData that's giving you the error?

    If so, make sure you include "New" somewhere. The object needs to be instantiated to work.

    Also, in .Net you might want to look into ADO.Net instead of legacy ADO. There's a good tutorial in techgnome's signature. Should be able to explain all you need. There's also numerous threads on VBF made about ADO.Net.

  3. #3
    Fanatic Member jcavard's Avatar
    Join Date
    Jul 2005
    Location
    Quebec, CANADA
    Posts
    534

    Re: Error: Object reference not set to an instance of an object

    i guess you didn't set
    [Highlight=VB]rsCustomerData = new recordset [/vbcod]

    but it's not .net and im not familir, but it would be my bet. as 7halo said, you should check .net object like dataset and datatable and dataadapter and dataview and datarelation and datarow and dataALLtheWAY...
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

    accoustic emo-rock band: a tailormade fable

    Visual Studio 2003 / Framework 1.1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width