locked
Programmatically Delete Data From Gridview RRS feed

  • Question

  • User1109811461 posted
    hi all expertise i need help

      below is my code, the problem is when i click the button it does not give any responce, i don;t what is the mistake

       please see my code below:

     
    If e.CommandName = "DeleteData" Then
    
                Dim IdPelajarDelete As String = e.CommandArgument.ToString()
                Dim mySQLConnection = New SqlConnection()
                mySQLConnection.ConnectionString = ConfigurationManager.ConnectionStrings("default").ConnectionString
    
                mySQLConnection.Open()
                Dim cmd As New SqlCommand()
                cmd.Connection = mySQLConnection
                cmd = New SqlCommand("delete from MaklumatPelajar where IdPelajar=" + IdPelajarDelete + "", mySQLConnection)
                mySQLConnection.Close()
    


     

     

    Friday, January 4, 2013 10:11 AM

Answers

  • User-1247037355 posted

    You missed Command.ExcuteNonQuery()

       for change it

                mySQLConnection.Open()
                Dim cmd As New SqlCommand()
                cmd.Connection = mySQLConnection
                cmd = New SqlCommand("delete from MaklumatPelajar where IdPelajar=" + IdPelajarDelete + "", mySQLConnection)
                cmd.ExcuteNonQuery()
                mySQLConnection.Close()
    
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 4, 2013 10:32 AM

All replies

  • User1690870723 posted

    Add your aspx page code

    Friday, January 4, 2013 10:16 AM
  • User-1716253493 posted
    set button CommandArgument='<%# Eval("IdPelajar") %>'
    Friday, January 4, 2013 10:29 AM
  • User-1247037355 posted

    You missed Command.ExcuteNonQuery()

       for change it

                mySQLConnection.Open()
                Dim cmd As New SqlCommand()
                cmd.Connection = mySQLConnection
                cmd = New SqlCommand("delete from MaklumatPelajar where IdPelajar=" + IdPelajarDelete + "", mySQLConnection)
                cmd.ExcuteNonQuery()
                mySQLConnection.Close()
    
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 4, 2013 10:32 AM
  • User1109811461 posted

    hi ramramesh

    you resolve my problem, i got it, rushing to resolve this probelmCool

    Friday, January 4, 2013 9:14 PM