473,394 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Display Search Results in DataGrid

1
hyy all
I m new to C#, so please ignore if I use wrong terms.
I m working on a single form application in VS2010, with sql database. I have successfully inserted the data in to database table.

but search is the problem, when ever i try to perform the search the datagridview control displays all the data present in the database.

this is what I m doing...
Expand|Select|Wrap|Line Numbers
  1. private void btnSearchName_Click(object sender, EventArgs e)
  2.         {
  3.             try
  4.             {
  5.                 sqlcon.Open();
  6.                 sqlcmd = new SqlCommand("select * from tblContacts where NAME = ('"+ txtSearchName.Text +"')") ;
  7.                 sqlcon.Close();
  8.  
but this query returns all the data present in the database, please see attachment.

thanks
Attached Images
File Type: jpg Untitled.jpg (31.7 KB, 88 views)
Aug 27 '14 #1
0 1192

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Alexandre Plennevaux | last post by:
hello mates, i want to set up a searchable database out of a huge word document containing reglementary articles (75 pages). The way i want the system to work is as such: a search form...
2
by: CharitiesOnline | last post by:
Hello, I have set this script up to add paging to a search results page. Which on the first page works fine. I calculates how many pages there should be depending on the number of results returned...
3
by: Jimmy | last post by:
Hi I want to display an empty datagrid if my datasource has zero results. How to do this? thanks J.
2
by: Steven Smith | last post by:
Hi guys What I'm trying to do today is display the results from an SQL query on one table in a Datagrid I'm using the following code to query the table. \\\ Try If...
4
by: Dica | last post by:
i apologize for what is no doubt a very rudimentary question, but i'm still trying to wrap my brain around .net coding habits. in classic asp, if i wanted to show search results, i'd just post the...
0
by: =?Utf-8?B?Qm9ubmll?= | last post by:
I have a basic ASP / Index Server search page. I have a web site contained in a subdirectory in the root of a main web site. What I’m trying to do is force the search page in the subdirectory,...
4
by: PI | last post by:
Hi guys, I'm struggling with this much longer than I think I need to, I guess you could help me here: How do I make the results of a search display on the same page as the search, sort of beneath...
16
by: dougmeece | last post by:
Good day everyone, I have a database with 2 main forms. The first form is used to add records to the database and contains a command button that opens the 2nd form for records searching. On...
5
by: moorcroft | last post by:
Hi I have developed an application that people can use to search for planning applications. The way it works is that once search criteria has been selected and submit is hit, the server will save...
0
geforceGTX480
by: geforceGTX480 | last post by:
So, I can't seem to get a sample code that works. I have a web form that will have input fields. These fields will be used as input parameters for the MSSQL stored procedure. From there we are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.