Private Sub delete_Click(sender As System.Object, e As System.EventArgs) Handles delete.Click

    Try
        Dim con As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=D:\JENNY PROJECT\JENNYFER\SMS project\SMS project\Database1.mdf;Integrated Security=True;User Instance=True")
        con.Open()
        Dim query As String
        query = "delete from course_tabl where c_name='" + ComboBox1.Text + "'"
        cmd = New SqlCommand(query, con)
        dr = cmd.ExecuteReader
        MessageBox.Show("Do you really want to delete?", "DELETE", MessageBoxButtons.YesNo)

        MessageBox.Show(" Successfully Deleted", " DATA DELETED ", MessageBoxButtons.OK, MessageBoxIcon.Information)
        ComboBox1.Refresh()
        ComboBox1.Text = ""
        c_code.Text = ""
        c_name.Text = ""
        cu_dur.Text = ""
        cu_fees.Text = ""
        con.Close()
    Catch ex As SqlException
        MessageBox.Show(ex.Message)
    Finally

        con.Dispose()
    End Try

End Sub
Be a part of the DaniWeb community

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