Help with SQL syntax


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Help with SQL syntax

  1. #1
    Roy Guest

    Re: Help with SQL syntax

    strLastName = "me"
    strSQL = "SELECT * FROM members WHERE lastname LIKE " & "'*" & strLastName &
    "*'"

    Regards,
    Roy

    "W.Pierce" <piercewe@co.forsyth.nc.us> wrote in message
    news:3c0b93cc$2@147.208.176.211...
    >
    > Can anyone please tell me the proper syntax of an SQL statement
    > when I need it to perform the following condition?
    >
    > I have a textbox called ....txt32
    > the field name is called..... lastname
    > The table is called.......members
    >
    > What I want to do, is to be able to type into the text box something
    > like...... me* .....and have a search performed on the field called
    > lastname and get it to return everything that contains the (me), such
    > as Mecham, mechanic, me a moron, merry christmas, me program don't work,
    >
    > name, stopme, and so forth......
    >
    > I suspect the sql line would be something like...
    >
    > SELECT * FROM members WHERE lastname LIKE............and then I get
    > lost......I have tried several combinations, but can't figure out
    > how to get the contents of a text box recognized in an sql
    > statement, especially if I want to do a wildcard search using * .....
    >
    > Could someone give me the correct syntax including correct punctuation
    > using the above parameters.....
    >
    > thanks a bunch.
    > william




  2. #2
    W.Pierce Guest

    Help with SQL syntax


    Can anyone please tell me the proper syntax of an SQL statement
    when I need it to perform the following condition?

    I have a textbox called ....txt32
    the field name is called..... lastname
    The table is called.......members

    What I want to do, is to be able to type into the text box something
    like...... me* .....and have a search performed on the field called
    lastname and get it to return everything that contains the (me), such
    as Mecham, mechanic, me a moron, merry christmas, me program don't work,

    name, stopme, and so forth......

    I suspect the sql line would be something like...

    SELECT * FROM members WHERE lastname LIKE............and then I get
    lost......I have tried several combinations, but can't figure out
    how to get the contents of a text box recognized in an sql
    statement, especially if I want to do a wildcard search using * .....

    Could someone give me the correct syntax including correct punctuation
    using the above parameters.....

    thanks a bunch.
    william

  3. #3
    Miguel Cabašo Guest

    Re: Help with SQL syntax


    "Roy" <iroy55@hotmail.com> wrote:
    >strLastName = "me"
    >strSQL = "SELECT * FROM members WHERE lastname LIKE " & "'*" & strLastName

    &
    >"*'"
    >
    >Regards,
    >Roy
    >
    >"W.Pierce" <piercewe@co.forsyth.nc.us> wrote in message
    >news:3c0b93cc$2@147.208.176.211...
    >>
    >> Can anyone please tell me the proper syntax of an SQL statement
    >> when I need it to perform the following condition?
    >>
    >> I have a textbox called ....txt32
    >> the field name is called..... lastname
    >> The table is called.......members
    >>
    >> What I want to do, is to be able to type into the text box something
    >> like...... me* .....and have a search performed on the field called
    >> lastname and get it to return everything that contains the (me), such
    >> as Mecham, mechanic, me a moron, merry christmas, me program don't work,
    >>
    >> name, stopme, and so forth......
    >>
    >> I suspect the sql line would be something like...
    >>
    >> SELECT * FROM members WHERE lastname LIKE............and then I get
    >> lost......I have tried several combinations, but can't figure out
    >> how to get the contents of a text box recognized in an sql
    >> statement, especially if I want to do a wildcard search using * .....
    >>
    >> Could someone give me the correct syntax including correct punctuation
    >> using the above parameters.....
    >>
    >> thanks a bunch.
    >> william

    >

    Hello my name is Miguel i'm from Portugal and i think i've your problem

    First the sql statment is wrong

    the statment that you need to write is something like this

    select * from your table where bla='your value'
    well if you have an textbox

    you write like this

    format to string is like this

    "select * from your table where bla='" + textbox + "'"


    if you want to send me the code i can fix it .


    best regards

    Miguel Cabašo



  4. #4
    huibert Guest

    Re: Help with SQL syntax


    "W.Pierce" <piercewe@co.forsyth.nc.us> wrote:
    >
    >Can anyone please tell me the proper syntax of an SQL statement
    >when I need it to perform the following condition?
    >
    >I have a textbox called ....txt32
    >the field name is called..... lastname
    >The table is called.......members
    >
    >What I want to do, is to be able to type into the text box something
    >like...... me* .....and have a search performed on the field called
    >lastname and get it to return everything that contains the (me), such
    >as Mecham, mechanic, me a moron, merry christmas, me program don't work,
    >
    >name, stopme, and so forth......
    >
    >I suspect the sql line would be something like...
    >
    >SELECT * FROM members WHERE lastname LIKE............and then I get
    >lost......I have tried several combinations, but can't figure out
    >how to get the contents of a text box recognized in an sql
    >statement, especially if I want to do a wildcard search using * .....
    >
    >Could someone give me the correct syntax including correct punctuation
    >using the above parameters.....
    >
    >thanks a bunch.
    >william


    In your code, for example in the Click event of that commandbutton that makes
    the grid appear, put the following:

    yourgrid.recordsource = "SELECT * FROM members WHERE lastname LIKE '" & txt32.text
    & "%'"

    if that doesn't work, then put an * instead of the %.

    The above statements should not give a syntax error!!!

    hth
    huibert


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center