Delete row from database using oledbcommand

Posted on 2006-04-29
Last Modified: 2010-08-05
Hi experts,

here is my code, i just want to delete a row in the database based on an SQL statement

Dim cn As OleDbConnection

'connection string (path of database)
        strConn = "Provider = Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & dataSource

        'creating a new connection object with connection string
        cn = New OleDbConnection(strConn)

        'opening the connection

strSQL = "DELETE * " & _
            "FROM PlayList " & _
            "WHERE userID = " & userID & " AND playListTitle = " & playListName & " "

            cmd = New OleDbCommand(strSQL, cn)
            cmd.ExecuteNonQuery()       '*****ERROR*****  no value given for one or more required parameters

I have no idea what the error above means but need this working today!
Question by:ab2ae
    LVL 69

    Accepted Solution

    Hi ab2ae,

    1. Remove the * after the Delete keyword
    2. characters fields must have values surrounded by single quotes

    strSQL = "DELETE  " & _
                "FROM PlayList " & _
                "WHERE userID = " & userID & " AND playListTitle = '" &  playListName & "' "


    Author Comment

    brilliant!! :o)

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now