dcsimg
Results 1 to 13 of 13

Thread: [RESOLVED] Incorrect syntax near ','.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2009
    Location
    Milton Keynes
    Posts
    29

    Resolved [RESOLVED] Incorrect syntax near ','.

    Hello All!

    I am having some issues with a sql statement, i am using SQL server 2005 Express edition and my application is an ASP.net website written in VB.NET.

    PHP Code:
    "SELECT [Parent_Id], [Type_Id], [Page_Id] FROM tblPages WHERE [Parent_Id]=" claGetObjects.Site ", [Type_Id]=6; 
    can anyone see where i am going wrong? i have checked my variables and they have the desired values for the sql command.

    Any Ideas?

    PsYmEz

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,415

    Re: Incorrect syntax near ','.

    If you want multiple conditions in a Where clause, join them with the keywords AND or OR, depending on the behaviour you want.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2009
    Location
    Milton Keynes
    Posts
    29

    Re: Incorrect syntax near ','.

    Thanks indeed! Thats solved that issues for me! Thanks!!

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Dec 2009
    Location
    Milton Keynes
    Posts
    29

    Re: Incorrect syntax near ','.

    im having the same issue with this sql statement

    "SELECT [Default], [Default_Page] FROM tblSites WHERE [Default]=1;"

    these problems have started since i moved to sql server 2005 from access 2007 is there a different way i need to format the sql strings for sql server 2005?

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,415

    Re: Incorrect syntax near ','.

    Remove the ; character from the end, only Access uses it (and it isn't even needed for Access).

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Dec 2009
    Location
    Milton Keynes
    Posts
    29

    Re: Incorrect syntax near ','.

    Thanks Si i have removed the ; from the end but i am still getting the syntax error? Im so confused as these strings worked fine with Access.... YIKES!!

    any other ideas?

    PsYmez

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,415

    Re: Incorrect syntax near ','.

    There isn't anything else obviously wrong.

    What is the actual error message you are getting?

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Dec 2009
    Location
    Milton Keynes
    Posts
    29

    Re: Incorrect syntax near ','.

    Incorrect syntax near ','.

    is the error i am getting ignore my last post as i had forgotten to add a breakpoint and was confused as to where i was debugging. I am however getting teh same error on a different sql statement which again seems fine to me... Its below, can you see anything si?

    clasql.sqlReader("SELECT [Title], [Parent_Id], [Page_Id], [Requires_Login] FROM tblPages WHERE [Page_Id]=" & Page)

    Thanks again buddy!!

  9. #9
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Incorrect syntax near ','.

    Check the actual SQL statement passed to database... incorrect comma could have been in variable Page... do a Debug.Print

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Dec 2009
    Location
    Milton Keynes
    Posts
    29

    Re: Incorrect syntax near ','.

    im actually being a bit dim, its not the sql statement thats causing errors. Thanks for everyones input!

    Solved!!

  11. #11
    Junior Member Augusto100's Avatar
    Join Date
    Aug 2019
    Location
    Bolivia
    Posts
    16

    Re: [RESOLVED] Incorrect syntax near ','.

    Please help im getting and error in this statement Private Sub BtnBorrar_Click(sender As Object, e As EventArgs) Handles btnBorrar.Click
    Dim CodigoInterno As String
    CodigoInterno = Me.cmbCodigoInternoEDC.Text
    cmd.CommandType = CommandType.Text
    cmd.Connection = conn

    sql = "delete from [Equipos de Computacion] and Vehiculos where CodigoInterno= " & CodigoInterno & ""
    cmd.CommandText = sql

    Try
    cmd.ExecuteNonQuery()
    Me.cmbCodigoInternoEDC.Text = ""
    Me.cmbCodigoInternoVH.Text = ""
    llenaCombo()



    MsgBox("Registro eliminado correctamente")

    Catch ex As Exception

    MsgBox(ex.ToString)

    End Try

    End Sub

  12. #12
    Junior Member Augusto100's Avatar
    Join Date
    Aug 2019
    Location
    Bolivia
    Posts
    16

    Re: [RESOLVED] Incorrect syntax near ','.

    both tables have codigo Interno as primary key i want to erase both.

  13. #13
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,796

    Re: [RESOLVED] Incorrect syntax near ','.

    1) Don't hijack someone else's thread with your own problems.
    2) This thread is also 10 years old.
    3) Your problem is that you're using completely wrong syntax. I noted this in your thread. You'll need to use two statements. Delete from one table first, then the other.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width