can u help me about this

Recommended Answers

All 5 Replies


runtime error

Can you please paste your code here? so that we can help..

Private Sub Deletebutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim sqlDeleteItem As String
        Dim a As Integer
        Dim db As SqlCommand
        Dim answer As Integer

        a = DataGridView1.Item(0, DataGridView1.CurrentRow.Index).Value
        answer = MsgBox("Do you want to delete the User?", MsgBoxStyle.YesNo + MsgBoxStyle.Question, "")
        If answer = vbYes Then
            sqlDeleteItem = "delete from Users where User_id = " & a & ""
            db = New SqlCommand(sqlDeleteItem, con)
            MsgBox("User Deleted!", MsgBoxStyle.Information, "")
            da = New SqlDataAdapter("Select * from Users", con)
            da.Fill(ds, "Users")
            DataGridView1.DataSource = ds.Tables("Users").DefaultView
        End If
    End Sub


I am not familiar with DataGrid with vb, and i use ListView a lot of times.

maybe you can adopt this code and can give you an idea how to delete selected record.

sql "DELETE * FROM tblpwd where modusername = '" & lstUsers.SelectedItem.Text & "' "
lstUsers.ListItems.Remove (lstUsers.SelectedItem.Index)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.