SQL fieldname equals data from a textbox in a select statement

Posted on 2005-04-26
Last Modified: 2012-06-21

Well my question is :

How do I create a SQL Select statement that uses the Text value from a VB.NET textbox ?

Select *  From textbox2.text     or Select textbox1.text From textbox2.text

What is the correct syntax if I am using a Textbox or Combobox ?

Question by:abennett10
    LVL 96

    Accepted Solution

    "Select * From '" & textbox2.text & "'"

    "Select " & textbox1.text & " From " & textbox2.text

    LVL 35

    Expert Comment

    select * from Table1 where field1 ='" & TextBox1.Text & "'" (if value is a string)

    select * from Table1 where field1 =" & TextBox1.Text  (if value is numeric)

    select * from Table1 where field1 =" & ComboBox1.SelectedValue


    select * from Table1 where field1 ='" & ComboBox1.SelectedText & "'"

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Article by: jpaulino
    XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
    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…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    728 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

    21 Experts available now in Live!

    Get 1:1 Help Now