0

i get this whenever i run this specific form and i do not know why this keep showing, pls help me how to solve this i do not know how to, i do not know what this means but as far as i know my other forms work perfectly fine

system.nullreferenceexception 'object reference not set to an instance of an object.' vb.net 

This is the code:

public database as ADODB.Connection
public table as ADODB.RecordSet
Private Sub frmSales_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        database.Open("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Windows10\Downloads\FinalsProject.accdb")
        table.Open("select * from TB_Transactions", database, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
        table.MoveFirst()

        Call DisplayRecord()
        Call DisabledControl()
 End Sub

enter image description here

D T
  • 3,522
  • 7
  • 45
  • 89

1 Answers1

1

Your must init database, table before use:

 database = New ADODB.Connection()
 table = New ADODB.Recordset()
D T
  • 3,522
  • 7
  • 45
  • 89