Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 13-07-2009
Member
 
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
Reply With Quote
  #2  
Old 13-07-2009
Member
 
Join Date: Dec 2007
Posts: 1,592
Re: sql to work in text box

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

Hope this helps.
Reply With Quote
  #3  
Old 13-07-2009
Member
 
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";
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "sql to work in text box"
Thread Thread Starter Forum Replies Last Post
TEXT message icon not showing text messages in BlackBerry curve 8520 Tabita Portable Devices 5 28-02-2011 08:23 PM
BlackBerry Torch TEXT message icon not showing text messages rOSAMOND Portable Devices 8 17-10-2010 01:04 AM
Samsung E1120 text message don't work Gaganadipika Portable Devices 5 22-04-2010 05:22 PM


All times are GMT +5.5. The time now is 10:49 PM.