I was wondering if there is a code i could add to my applicatio that will delete a data entry from a database. I'm designing a voting application as my project and i want a situation where an access code is good for only one entry. i put my code for retrieving the code below.
Is there anything that i can add to the code that will delete the entry that was used to login immediately after authentication?
Private Sub btnCodeEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCodeEnter.Click Dim connect As String Dim query As String Dim dbProvider As String Dim dbsource As String dbProvider = "PROVIDER=Microsoft.ACE.OLEDB.12.0;" dbsource = "Data Source =|DataDirectory|\Codes.accdb" connect = dbProvider & dbsource query = "Select Count(*) From tblCodes Where Codes = ?" Dim result As Integer = 0 Using conn As New OleDb.OleDbConnection conn.ConnectionString = connect conn.Open() Using cmd As New OleDb.OleDbCommand(query, conn) cmd.Parameters.AddWithValue("", txtCode.Text) result = DirectCast(cmd.ExecuteScalar(), Integer) End Using End Using If result > 0 Then frmVotingPlatform2.Show() Me.Hide() ElseIf txtCode.Text = PlatformPassword Then frmAdminCntrl.Show() Me.Hide() Else MsgBox("Invalid code. Please enter correct code", vbExclamation) txtCode.Focus() End If End Sub