I am creating a 'delete user account' button for my vb.net app. There may be some tables the user created, which need to be deleted along with the user's account. Any table the user created will be named with the user's id and a number. ex: 'sam_21', 'sam_45'. how can I drop all tables that have start with 'sam_"?
would it be something like:
dim userID = Users.Identity.Name
cmd = New SqlCommand("DROP table_name WHERE table_name LIKE @userId")
cmd.Parameters.AddWithValue("@userId", userID & "_%")
dc.Open()
cmd.ExecuteNonQuery()
dc.Close()
Membership.DeleteUser(User.Identity.Name)
FormsAuthentication.SignOut()
FormsAuthentication.RedirectToLoginPage()
But how do I deal with the table-name aspect of the statement when that is also the variable?