473,382 Members | 1,784 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,382 software developers and data experts.

problem with search application

hi friends please help me with my problem i have a code for search application it is searching one record from the data base at a time but i have so many records with that name but its not searching the whole list please help me how i can search the whole list of the same names
my code is like this
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Report.aspx.cs" Inherits="SearchReport.Report" %>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4.  
  5. <html xmlns="http://www.w3.org/1999/xhtml" >
  6. <head runat="server">
  7.     <title>Report</title>
  8. </head>
  9. <body>
  10.     <form id="form1" runat="server">
  11.     <div>
  12.     <table cellpadding="0" width="700" align="center" border="1">
  13.     <tr>
  14.     <td height="50"><img src="header.jpg" alt="header" width="700"/>
  15.     </td>
  16.     </tr>
  17.     <tr>
  18.     <td>
  19.     Search:
  20.     <asp:TextBox ID="txtreport" runat="server"></asp:TextBox>
  21.      <asp:DataGrid ID="gridreport" runat="server" AutoGenerateColumns="false">
  22.      <Columns>
  23.      <asp:BoundColumn DataField="Name" HeaderText="Name" HeaderStyle-BackColor="Gray"></asp:BoundColumn>
  24.      <asp:BoundColumn DataField="Path" HeaderText="Path" HeaderStyle-BackColor="gray"></asp:BoundColumn>
  25.      <asp:BoundColumn DataField="Description" HeaderText="Description" HeaderStyle-BackColor="gray"></asp:BoundColumn>
  26.  
  27.      </Columns>
  28.  
  29.      </asp:DataGrid>
  30.     </td>
  31.     </tr>
  32.     <tr>
  33.     <td>
  34.     <asp:Button ID="cmdbutton" align="center" Text="Search" runat="server" OnClick="cmdbutton_Click" />
  35.     </td>
  36.     </tr>
  37.     </table>
  38.     </div>
  39.     </form>
  40. </body>
  41. </html>
  42.  
  43.  
  44.  
  45.  
  46. using System;
  47. using System.Data;
  48. using System.Configuration;
  49. using System.Collections;
  50. using System.Web;
  51. using System.Web.Security;
  52. using System.Web.UI;
  53. using System.Web.UI.WebControls;
  54. using System.Web.UI.WebControls.WebParts;
  55. using System.Web.UI.HtmlControls;
  56. using System.Data.SqlClient;
  57. using System.Data.SqlTypes;
  58.  
  59. namespace SearchReport
  60. {
  61.     public partial class Report : System.Web.UI.Page
  62.     {
  63.         protected void Page_Load(object sender, EventArgs e)
  64.         {
  65.  
  66.         }
  67.  
  68.         protected void txtreport_TextChanged(object sender, EventArgs e)
  69.         {
  70.  
  71.         }
  72.  
  73.         protected void cmdbutton_Click(object sender, EventArgs e)
  74.         {
  75.             SqlConnection oConn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["oConn"]);
  76.             SqlDataAdapter da = new SqlDataAdapter("dbo.win_ReportListSearch", oConn);
  77.             da.SelectCommand.CommandType = CommandType.StoredProcedure;
  78.  
  79.  
  80.             DataSet ds = new DataSet();
  81.  
  82.                da.SelectCommand.Parameters.Add(new SqlParameter("@Name",txtreport.Text));
  83.  
  84.               //if (txtreport.Text.ToString() != "")
  85.               //{
  86.                //da.SelectCommand.Parameters.Add(new SqlParameter("@Name", txtreport.Text));
  87.                //}
  88.  
  89.             oConn.Open();
  90.             da.SelectCommand.ExecuteNonQuery();
  91.             oConn.Close();
  92.  
  93.             da.Fill(ds);
  94.  
  95.             this.gridreport.DataSource = ds;
  96.             this.DataBind();
  97.  
  98.             da.Dispose(); 
  99.  
  100.         }
  101.     }
  102. }
  103.  
  104.  
  105.  


and the store procedure is like this

Expand|Select|Wrap|Line Numbers
  1. ALTER PROCEDURE [dbo].[win_ReportListSearch]
  2. @Name varchar(30)
  3. as
  4.  
  5.  
  6. SELECT [Name],
  7.        [Path],
  8.        [Description]
  9. FROM Catalog
  10. WHERE [Name] like (@name)
  11.  
  12.  
  13. please help me with this problem
  14.  
  15.  
Dec 26 '07 #1
2 1089
Shashi Sadasivan
1,435 Expert 1GB
Please try the following

Expand|Select|Wrap|Line Numbers
  1. ALTER PROCEDURE [dbo].[win_ReportListSearch]
  2. @Name varchar(30)
  3. as
  4.  
  5.  
  6. SELECT [Name],
  7.        [Path],
  8.        [Description]
  9. FROM Catalog
  10. WHERE [Name] like ('%'+@name+'%')
the % symbols are place holders allowing the name to be at any location in the text

Your previous code was as good as "Where [Name] = @name"
Dec 27 '07 #2
thanks so much it worked for me thanks once again to helping me with this problem
Dec 27 '07 #3

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

Similar topics

1
by: Pierre Rouleau | last post by:
Hi all, When building a exe for a Python application under Windows XP with The McMillan installer, the insttaltion succeeds but when I run the resulting executable the application tracebacks...
1
by: Phil Powell | last post by:
I read numerous accounts about how to set ft_min_word_len only which cannot be done using the SET statement. The client wants to be able to use a portable web application I built, with its own...
7
by: Amar | last post by:
I am trying to connect to my college LDAP directory using ASP.NET. This LDap does not have security as it returns only user demographic information. i do not need to bind with a username or...
13
by: Simon Matthews | last post by:
I am having issues with the right way to architecture the following (using c# asp.net):- The question I have is how best pass the collected data from one web page for use in another. The...
1
by: Sunil Sabir | last post by:
Dear All, I have a search form which has 3 drop down boxes dropID ,dropPostCode, dropName. when I select some thing in the dropID name lets say 0001 I press go button.It displays a Record of...
13
by: Giggle Girl | last post by:
Hi there, I am having a problem with the behavior of Firefox, where lefthand column content is not resized properly after it is "collapsed" and then "re-expanded". An online demo is available...
4
by: shreshth.luthra | last post by:
Hi All, I am having a GUI which accepts a Unicode string and searches a given set of xml files for that string. Now, i have 2 XML files both of them saved in UTF-8 format, having characters...
1
by: Blackstar | last post by:
I have a website I am trying to download a file from. This website is strange in the fact that there is no direct link to the URL of the file. The way the site works is as follows: 1) Enter in...
19
by: foolsmart2005 | last post by:
I have written a snake game. There are 2 levels in the game(I finished 1st level). It can run in VC++ without problem but, when I run it on the dev C++ 4.9.9.2, it cannot run. I want to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.