here are code in vb.net when ever i try to delete entry... this error occurs . Null reference Exception was unhandled....Us e new key word to create an object reference.Plz if anyone can help how can i solve this problem.
Code:
Private Sub Deldata(ByRef dfname As String)
Dim Dc As DAO.Recordset
CurDb = CurrentDb
Dim SSTR As String
Dc = CurrentDb.OpenRecordset("tableName", DAO.RecordsetTypeEnum.dbOpenDynaset)
SSTR = "Cto = '" & dfname & "'"
Dc.FindFirst(SSTR)
If Not (Dc.NoMatch) Then
MsgBox("Column being used in other entries. Can't delete", 64, "Abhiraj")
DelFlag = True
Dc.Close()
Exit Sub
End If
Dim ds As DAO.Recordset
Dim Searchstr As String
ds = CurDb.OpenRecordset("Columns", DAO.RecordsetTypeEnum.dbOpenDynaset)
Searchstr = "CName = '" & dfname & "'"
ds.FindFirst(Searchstr)
If ds.NoMatch Then
MsgBox("No such column found", 11, "Abhiraj")
ds.Close()
Exit Sub
End If
If ds.Fields(4).Value = 0 And ds.Fields(5).Value = 0 Then
MsgBox("Column being used in other entries. Can't delete", 64, "Abhiraj")
DelFlag = True
Exit Sub
End If
ds.Delete()
ds.Close()
Dc.Close()
End Sub
Comment