Incorrect syntax near '*'

Discussion in 'ASP .Net' started by Mario Krsnic, Jan 27, 2007.

  1. Mario Krsnic

    Mario Krsnic Guest

    Hallo zusammen,
    I have an app. with SQL-Server. The same page worked fine with Access-DB.
    Now I have a problem with this command:

    Dim strSQL As String

    Dim myConnection As New
    SqlConnection("server=mssql07.1und1.de;uid=dbo88888888;pwd=8888888;database=db88888888")

    myConnection.Open()

    strSQL = "delete * from tbl1 where id =" & n

    Dim myCommand As New SqlCommand(strSQL, myConnection)

    myCommand.ExecuteNonQuery()

    myConnection.Close()

    if I try to perform the command I get this message:

    Incorrect syntax near '*'

    What is the right syntax?
    Thank you!
    Mario
     
    Mario Krsnic, Jan 27, 2007
    #1
    1. Advertising

  2. Howdy,

    SQL server does not understand * in delete statement.
    strSQL = "delete from tbl1 where id =" & n

    --
    Milosz


    "Mario Krsnic" wrote:

    > Hallo zusammen,
    > I have an app. with SQL-Server. The same page worked fine with Access-DB.
    > Now I have a problem with this command:
    >
    > Dim strSQL As String
    >
    > Dim myConnection As New
    > SqlConnection("server=mssql07.1und1.de;uid=dbo88888888;pwd=8888888;database=db88888888")
    >
    > myConnection.Open()
    >
    > strSQL = "delete * from tbl1 where id =" & n
    >
    > Dim myCommand As New SqlCommand(strSQL, myConnection)
    >
    > myCommand.ExecuteNonQuery()
    >
    > myConnection.Close()
    >
    > if I try to perform the command I get this message:
    >
    > Incorrect syntax near '*'
    >
    > What is the right syntax?
    > Thank you!
    > Mario
    >
    >
    >
    >
    >
     
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=, Jan 27, 2007
    #2
    1. Advertising

  3. Mario Krsnic

    Mark Rae Guest

    "Mario Krsnic" <krsnic.de/> wrote in message
    news:epg5pe$1st$...

    > strSQL = "delete * from tbl1 where id =" & n


    Remove the asterisk.
     
    Mark Rae, Jan 27, 2007
    #3
  4. Mario Krsnic

    Mario Krsnic Guest

    Thank you!

    "Mark Rae" <> schrieb im Newsbeitrag
    news:...
    > "Mario Krsnic" <krsnic.de/> wrote in message
    > news:epg5pe$1st$...
    >
    >> strSQL = "delete * from tbl1 where id =" & n

    >
    > Remove the asterisk.
    >
     
    Mario Krsnic, Jan 27, 2007
    #4
  5. Try the percentage sign ( % ).

    > strSQL = "delete % from tbl1 where id =" & n


    The asterisk ( * ) only works in Access databases.



    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "Mario Krsnic" <krsnic.de/> wrote in message news:epg5pe$1st$...
    > Hallo zusammen,
    > I have an app. with SQL-Server. The same page worked fine with Access-DB. Now I have a problem
    > with this command:
    >
    > Dim strSQL As String
    >
    > Dim myConnection As New
    > SqlConnection("server=mssql07.1und1.de;uid=dbo88888888;pwd=8888888;database=db88888888")
    >
    > myConnection.Open()
    >
    > strSQL = "delete * from tbl1 where id =" & n
    >
    > Dim myCommand As New SqlCommand(strSQL, myConnection)
    >
    > myCommand.ExecuteNonQuery()
    >
    > myConnection.Close()
    >
    > if I try to perform the command I get this message:
    >
    > Incorrect syntax near '*'
    >
    > What is the right syntax?
    > Thank you!
    > Mario
    >
    >
    >
    >
     
    Juan T. Llibre, Jan 27, 2007
    #5
  6. Please ignore this comment:
    > Try the percentage sign ( % ).
    >> strSQL = "delete % from tbl1 where id =" & n


    The correct statement is :

    > strSQL = "delete from tbl1 where id =" & n


    The percentage sign works with the LIKE statement.




    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "Juan T. Llibre" <> wrote in message
    news:...

    > The asterisk ( * ) only works in Access databases.



    > Juan T. Llibre, asp.net MVP
    > asp.net faq : http://asp.net.do/faq/
    > foros de asp.net, en español : http://asp.net.do/foros/
    > ===================================
    > "Mario Krsnic" <krsnic.de/> wrote in message news:epg5pe$1st$...
    >> Hallo zusammen,
    >> I have an app. with SQL-Server. The same page worked fine with Access-DB. Now I have a problem
    >> with this command:
    >>
    >> Dim strSQL As String
    >>
    >> Dim myConnection As New
    >> SqlConnection("server=mssql07.1und1.de;uid=dbo88888888;pwd=8888888;database=db88888888")
    >>
    >> myConnection.Open()
    >>
    >> strSQL = "delete * from tbl1 where id =" & n
    >>
    >> Dim myCommand As New SqlCommand(strSQL, myConnection)
    >>
    >> myCommand.ExecuteNonQuery()
    >>
    >> myConnection.Close()
    >>
    >> if I try to perform the command I get this message:
    >>
    >> Incorrect syntax near '*'
    >>
    >> What is the right syntax?
    >> Thank you!
    >> Mario
    >>
    >>
    >>
    >>

    >
    >
     
    Juan T. Llibre, Jan 27, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Oct 11, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    10,747
    Patrick.O.Ige
    Oct 11, 2004
  2. Patrick Olurotimi Ige
    Replies:
    4
    Views:
    7,046
    Patrick Olurotimi Ige
    Mar 18, 2005
  3. JMUApache
    Replies:
    2
    Views:
    3,320
    Brendan Reynolds
    Sep 4, 2005
  4. David

    Incorrect syntax near 'int'

    David, Apr 6, 2006, in forum: ASP .Net
    Replies:
    7
    Views:
    2,491
    David
    Apr 7, 2006
  5. levis
    Replies:
    0
    Views:
    3,524
    levis
    Sep 20, 2006
Loading...

Share This Page