Results 1 to 3 of 3

Thread: sql to work in text box

  1. #1
    Join Date
    Feb 2009
    Posts
    96

    sql to work in text box

    OK this is taking place in VB.net 2008. I have created datagrids and a search text box where a user will enter a specific type of book for example if they enter business in the text box it will search the database and display all business books in the grid. I dont know how to get my SQL to work in that fashion in accordance with the text box.
    here is my SQL that i have

    ALTER PROCEDURE dbo.ParameterBookSalesByType


    as


    SELECT SUM(ytd_sales) AS [YTD_Sales], (SUM(ytd_sales) / COUNT(type)) AS [Average_Sales], type AS [Type], COUNT(type) AS [Books Sold]
    FROM titles
    WHERE type = type
    GROUP BY type

    now how do i get it to read from the text box and select the various books to display back to the grid.

    thanx

  2. #2
    Join Date
    Dec 2007
    Posts
    1,599

    Re: sql to work in text box

    Try:
    "SELECT * FROM (your table) WHERE (your field) = """ & textbox.text & """"

    Hope this helps.

  3. #3
    Join Date
    Nov 2008
    Posts
    1,221

    Re: sql to work in text box

    That's pretty simple. First except the value from the user. For instance, if a user types "business" (as you said). Now fire a query specifying all the fields that should be displayed in "SELECT" clause. Now the table in "FROM" clause. Bow match the value in the text box with the entries in the table in the "WHERE" clause. Optionally you can sort your result using "ORDER BY" clause.

    e.g.

    Code:
    SELECT * FROM books_collection WHERE books_type = "business";

Similar Threads

  1. Replies: 5
    Last Post: 28-02-2011, 08:23 PM
  2. BlackBerry Torch TEXT message icon not showing text messages
    By rOSAMOND in forum Portable Devices
    Replies: 8
    Last Post: 17-10-2010, 01:04 AM
  3. Samsung E1120 text message don't work
    By Gaganadipika in forum Portable Devices
    Replies: 5
    Last Post: 22-04-2010, 05:22 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,526,435.32577 seconds with 16 queries