• Delete Query Syntax Error (VB6, SQL Server 2K)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Delete Query Syntax Error (VB6, SQL Server 2K)

    Author
    Topic
    #373350

    The error reads Error near “*”. Here is the code it is trying to execute:

    CN.Execute (“DELETE * FROM tblEmpl WHERE FullName = ‘” + txtLastName.Text + “, ” + txtFirstName.Text + “‘”)

    I replaced the & with +’s, which I knew SQL Server was particular about. What is up with the * ?

    Viewing 1 reply thread
    Author
    Replies
    • #599847

      Mike, I think what you want is DELETE FROM, omitting the *.

      • #601210

        Dottie, Charlotte – thanks! This worked perfectly (and so much faster on the SQL server).

    • #599865

      Dottie’s right, Mike. The asterisk is not recognized as valid in that construction–one of the various pitfalls in moving from Access/Jet SQL to SQL Server.

      • #601225

        Okay, I’m in an Access 2002 ADP file trying to delete all records out of one of my tables. I’m trying:

        DELETE FROM dbo.tblHistory

        And it is giving me the same error “Near Delete” thing. I’ve also tried the * and that didn’t work either. Now, how do I delete from within an ADP?

        God, I’m sure glad we came up with a STANDARDIZED query language.

        • #601857

          Try creating a stored procedure (using the new button) like this: [indent]


          Create Procedure “StoredProcedure1”
          As
          set nocount on
          DELETE FROM dbo.tblHistory
          return


          [/indent]
          Then run it.

    Viewing 1 reply thread
    Reply To: Delete Query Syntax Error (VB6, SQL Server 2K)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: