Help on sql select statement

Posted on 2007-10-05
Last Modified: 2010-04-23
Hey, I'm using 2005.
I have this SELECT statement that goes like this

sql2 = "SELECT* from isimtable WHERE '" & CBSearchItem.Text & "' LIKE '" & cbItem.Text & "'"

this doesn't seem to do anything, if i put an actual column in place of cbsearchitem.text, then it works o.k., but if the value of cbsearchitem.text is the exact name of one of my columns, shouldn't i get the same results.  What's going on?
Question by:DustinHinkel
    LVL 142

    Accepted Solution

    assuming that cbsearchitem is the name of the column to search, and cbItem the value, and the database is ms sql server:

    sql2 = "SELECT * from isimtable WHERE [" & CBSearchItem.Text & "] LIKE '%" & cbItem.Text & "%'"

    you might want to specify those details...

    Author Comment

    you were correct in your assumptions except the database is an access database.  using oledb.  You're code worked perfectly.  Thank you very much.  I will try to be more specific in the future.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now