Re: sending a query to access in asp.net

Discussion in 'ASP .Net' started by Jon, Oct 11, 2005.

  1. Jon

    Jon Guest

    I don't know access but ANSI SQL needs single quotes '*@nombre*' around the
    string
    Also you probably don't want * but instead want %.


    "Ankit Aneja" <> wrote in message
    news:%...
    >
    > hi i want to be a this query in access with asp.net "select * from autores
    > where nombre like *@nombre* " but (*) this character is dont support in
    > the
    > query.... send this error
    >
    > Syntax error (missing operator) in query expression 'nombre like
    > ('*')@nombre('*')'.
    > Description: An unhandled exception occurred during the execution of the
    > current web request. Please review the stack trace for more information
    > about the error and where it originated in the code.
    >
    > Exception Details: System.Data.OleDb.OleDbException: Syntax error (missing
    > operator) in query expression 'nombre like ('*')@nombre('*')'.
    >
    >
    > I want to bring all the record that take or start with x word in someplace
    > example: it gives all records that take a text the word 'da' example ...
    > dany |dalila|dasces|darknes|this query in Access, SQL view thats work good
    > but when i try to send in asp.net dont work: ( whats happening....
    >
    > sub busca (s as object, e as eventargs)
    > dim objconn as oledbconnection
    > dim objcmd as oledbcommand
    > dim objrdr as oledbdatareader
    >
    > objconn = new oledbconnection( _
    > "Provider=Microsoft.Jet.Oledb.4.0; " & _
    > "data source=c:\Inetpub\wwwroot\kayun.mdb")
    > objcmd = new oledbcommand( _
    > "select * from autores where nombre like *@nombre*" ,objconn)
    > objcmd.parameters.add("@nombre",texto.text)
    > objconn.open()
    > objrdr = objcmd.executereader()
    > 'while objrdr.read()
    > 'response.write("Nombre: " & objrdr.item("nombre") & "<br />")
    > 'response.write("correo: " & objrdr.item("correo") & "<br />")
    > 'end while
    > repetidor.datasource= objrdr
    > repetidor.databind()
    > objrdr.close()
    > objconn.close()
    > end sub
    >
    >
    >
    Jon, Oct 11, 2005
    #1
    1. Advertising

  2. Jon

    Frankie Guest

    Re:
    << Also you probably don't want * but instead want %. >>

    Nope -
    % is for SQL Server
    while
    * is for Access





    "Jon" <> wrote in message
    news:...
    >I don't know access but ANSI SQL needs single quotes '*@nombre*' around the
    >string
    > Also you probably don't want * but instead want %.
    >
    >
    > "Ankit Aneja" <> wrote in message
    > news:%...
    >>
    >> hi i want to be a this query in access with asp.net "select * from
    >> autores
    >> where nombre like *@nombre* " but (*) this character is dont support in
    >> the
    >> query.... send this error
    >>
    >> Syntax error (missing operator) in query expression 'nombre like
    >> ('*')@nombre('*')'.
    >> Description: An unhandled exception occurred during the execution of the
    >> current web request. Please review the stack trace for more information
    >> about the error and where it originated in the code.
    >>
    >> Exception Details: System.Data.OleDb.OleDbException: Syntax error
    >> (missing
    >> operator) in query expression 'nombre like ('*')@nombre('*')'.
    >>
    >>
    >> I want to bring all the record that take or start with x word in
    >> someplace
    >> example: it gives all records that take a text the word 'da' example ...
    >> dany |dalila|dasces|darknes|this query in Access, SQL view thats work
    >> good
    >> but when i try to send in asp.net dont work: ( whats happening....
    >>
    >> sub busca (s as object, e as eventargs)
    >> dim objconn as oledbconnection
    >> dim objcmd as oledbcommand
    >> dim objrdr as oledbdatareader
    >>
    >> objconn = new oledbconnection( _
    >> "Provider=Microsoft.Jet.Oledb.4.0; " & _
    >> "data source=c:\Inetpub\wwwroot\kayun.mdb")
    >> objcmd = new oledbcommand( _
    >> "select * from autores where nombre like *@nombre*" ,objconn)
    >> objcmd.parameters.add("@nombre",texto.text)
    >> objconn.open()
    >> objrdr = objcmd.executereader()
    >> 'while objrdr.read()
    >> 'response.write("Nombre: " & objrdr.item("nombre") & "<br />")
    >> 'response.write("correo: " & objrdr.item("correo") & "<br />")
    >> 'end while
    >> repetidor.datasource= objrdr
    >> repetidor.databind()
    >> objrdr.close()
    >> objconn.close()
    >> end sub
    >>
    >>
    >>

    >
    >
    Frankie, Oct 12, 2005
    #2
    1. Advertising

  3. > Nope -
    > % is for SQL Server
    > while
    > * is for Access


    Only through the Access user interface. Access uses standard SQL wildcard
    syntax (% and ?) for queries executed via OLE DB.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Ambiguity has a certain quality to it.

    "Frankie" <> wrote in message
    news:%...
    > Re:
    > << Also you probably don't want * but instead want %. >>
    >
    > Nope -
    > % is for SQL Server
    > while
    > * is for Access
    >
    >
    >
    >
    >
    > "Jon" <> wrote in message
    > news:...
    >>I don't know access but ANSI SQL needs single quotes '*@nombre*' around
    >>the string
    >> Also you probably don't want * but instead want %.
    >>
    >>
    >> "Ankit Aneja" <> wrote in message
    >> news:%...
    >>>
    >>> hi i want to be a this query in access with asp.net "select * from
    >>> autores
    >>> where nombre like *@nombre* " but (*) this character is dont support in
    >>> the
    >>> query.... send this error
    >>>
    >>> Syntax error (missing operator) in query expression 'nombre like
    >>> ('*')@nombre('*')'.
    >>> Description: An unhandled exception occurred during the execution of the
    >>> current web request. Please review the stack trace for more information
    >>> about the error and where it originated in the code.
    >>>
    >>> Exception Details: System.Data.OleDb.OleDbException: Syntax error
    >>> (missing
    >>> operator) in query expression 'nombre like ('*')@nombre('*')'.
    >>>
    >>>
    >>> I want to bring all the record that take or start with x word in
    >>> someplace
    >>> example: it gives all records that take a text the word 'da' example ...
    >>> dany |dalila|dasces|darknes|this query in Access, SQL view thats work
    >>> good
    >>> but when i try to send in asp.net dont work: ( whats happening....
    >>>
    >>> sub busca (s as object, e as eventargs)
    >>> dim objconn as oledbconnection
    >>> dim objcmd as oledbcommand
    >>> dim objrdr as oledbdatareader
    >>>
    >>> objconn = new oledbconnection( _
    >>> "Provider=Microsoft.Jet.Oledb.4.0; " & _
    >>> "data source=c:\Inetpub\wwwroot\kayun.mdb")
    >>> objcmd = new oledbcommand( _
    >>> "select * from autores where nombre like *@nombre*" ,objconn)
    >>> objcmd.parameters.add("@nombre",texto.text)
    >>> objconn.open()
    >>> objrdr = objcmd.executereader()
    >>> 'while objrdr.read()
    >>> 'response.write("Nombre: " & objrdr.item("nombre") & "<br />")
    >>> 'response.write("correo: " & objrdr.item("correo") & "<br />")
    >>> 'end while
    >>> repetidor.datasource= objrdr
    >>> repetidor.databind()
    >>> objrdr.close()
    >>> objconn.close()
    >>> end sub
    >>>
    >>>
    >>>

    >>
    >>

    >
    >
    Kevin Spencer, Oct 12, 2005
    #3
    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. Steven Cheng[MSFT]

    RE: sending a query to access in asp.net

    Steven Cheng[MSFT], Oct 11, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    451
    Steven Cheng[MSFT]
    Oct 14, 2005
  2. Replies:
    0
    Views:
    1,338
  3. Eric Nelson
    Replies:
    5
    Views:
    1,512
    Alexey Smirnov
    Feb 4, 2009
  4. Kent
    Replies:
    2
    Views:
    112
  5. Roland Hall

    ASP LIKE query using parameterized query

    Roland Hall, Jan 12, 2007, in forum: ASP General
    Replies:
    8
    Views:
    208
    Roland Hall
    Jan 13, 2007
Loading...

Share This Page