Millkind
asked on
Object reference not set to an instance of an object. Probably Easy Answer.
This is throwing "Object reference not set to an instance of an object" for the line datarepairadapter.Fill(dat apartset).
Public Class datarepair
Public mainform As GCPOPTSselector
Dim datapartset As DataSet
Dim datarepairadapter As SqlDataAdapter
Private Sub SHOW_DATA(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles datarepairshowdatabutton.Click
Try
drsc.Enabled = True
datapartset = New DataSet
Dim datapart As New SqlDataAdapter
datapart = New SqlDataAdapter("Select * from data where DropOff between @sdate and @edate", mainform.conn)
datapart.SelectCommand.Parameters.Add("@sdate", SqlDbType.Date).Value = drsd.Value.Date
datapart.SelectCommand.Parameters.Add("@edate", SqlDbType.Date).Value = dred.Value.Date
datarepairadapter.Fill(datapartset)
datapartgrid.DataSource = datapartset.Tables(0)
mainform.RecordUserAction("Data Repair", "Filling grid with data table from " & drsd.Value.Date & " to " & dred.Value.Date)
Catch ex As Exception
mainform.errorwrite("Data Repair" & ex.ToString)
End Try
End Sub
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Nevermind. @CodeCruiser has it.
Change datarepairadapter.Fill(dat apartset) to datapart.Fill(datapartset)