none
Missing operator in query expression

    Question

  •  Apparently it does not see DELETE .
            strSQL = "DELETE [Names] WHERE [id] =" & g_ID
            cmd = New OleDbCommand(strSQL, cn)
            cmd.ExecuteNonQuery()
    I was wondering if it had to do with the name of the table.
    I replaced "Names" with a non existing table name just to see what would happen.
    strSQL = "DELETE [testing] WHERE [id] =" & g_ID
    Same error.  It never got to the table name.     
    I also tried (being desperate):
           strSQL = "DELETE" & " [Names] WHERE [id] =" & g_ID
    Same error
    Can anybody figure out what is happening?

    BraafPaard

    Friday, March 17, 2017 11:36 PM

Answers

  • Try "DELETE FROM [Names] WHERE id =" & g_id

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites


    Friday, March 17, 2017 11:48 PM
    Moderator

All replies

  • Try "DELETE FROM [Names] WHERE id =" & g_id

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites


    Friday, March 17, 2017 11:48 PM
    Moderator
  • Yes, that does the trick. Don't understand why FROM.  Wherever I looked I never saw FROM in the DELETE statement.

    Thanks again.


    BraafPaard

    Saturday, March 18, 2017 3:59 AM
  • Hello,

    Here is ms-access DELETE FROM. sql-server DELETE FROM.

    Basic syntax

    DELETE FROM table_name
    WHERE [condition];


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Saturday, March 18, 2017 8:53 AM
    Moderator