Click here to Skip to main content
15,913,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is my code....

Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting

VB
Dim vacid As Integer = Convert.ToInt32(DirectCast(GridView1.Rows(e.RowIndex).FindControl("txtVacid"), TextBox).Text)
      Dim myCommand As New SqlCommand
      Dim myConnection = New SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
      Dim update As String
      Dim strsql As String
      myCommand.Connection = myConnection
      'vacid = CInt(GridView1.Rows(GridView1.SelectedRow.RowIndex).Cells(0).Text)
      update = "Delete  from  Pat_Vaccine_Details   where vaccine_id='" & vacid & "'"
      myCommand = New SqlCommand(update, myConnection)
      myConnection.Open()
      myCommand.ExecuteNonQuery()
      myCommand.Connection.Close()
      BindGrid()
  End Sub


while deleting , i got this error

"null reference exception was unhandled "

please help
Posted

1 solution

Um...perhaps if you hadn't commented out the line which sets the vacid value it would help?

If it isn;t that, then you need to use the debugger to look at the line that is throwing the exception (and you haven't told us that) and find which value is null / Nothing and then look back in your code to find out why.

We can't do that for you: we can't run your code, see your screen, access your HDD, or read your mind...
 
Share this answer
 

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



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