Click here to Skip to main content
12,505,902 members (55,016 online)
 
See more: C#
public void LoadSearch()
       {
 

         try
          {
          SqlConnection connect = new SqlConnection();
              connect.ConnectionString =      ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
              connect.Open();
              SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM LOANS order by ID_CODE", connect);
 
              SqlCommand SqlCmd = new SqlCommand("sp_searchActLoan", connect);
              SqlCmd.CommandType = CommandType.StoredProcedure;
 
              SqlCmd.Parameters.AddWithValue("@searchString", txt_Search.Text);
              SqlCmd.ExecuteNonQuery();
 
              //SqlDataAdapter daa  = New SqlDataAdapter;
              //sqlDataAdapter.SelectCommand = sqlCmd;

             DataSet dsas = new DataSet();
 
            sqlDataAdapter.Fill(dsas, "searchResults");
 
              GridView1.DataSource = dsas;
              GridView1.DataBind();
 
          }
          catch (Exception ex)
           {
             lblStatus.Text=ex.Message;
           }
 
       }



stored procedure
-----------------
ALTER PROCEDURE [dbo].[sp_SearchActLoan]
(
	@searchString	varchar(500)
)
AS
BEGIN
	
	IF @searchString <> ''
	BEGIN
		CREATE TABLE #SearchResults
		(
			Zidno   	varchar(20),
			Zid_Code   	varchar(20),
			Zapprs_No  	varchar(20),
			ZCustomer  	varchar(60),	
			Zint_No		varchar(10),
			Zint_Name	varchar(50)
		)
 
		Insert Into #SearchResults(Zidno,Zid_Code,Zapprs_No,ZCustomer,Zint_No,Zint_Name)
		Select Distinct IDNO,ID_CODE,APPRS_NO,CUSTOMER,INT_NO,INT_NAME From LOANS
		Where IDNO Like '%' + @searchString + '%'
		Union
		Select Distinct IDNO,ID_CODE,APPRS_NO,CUSTOMER,INT_NO,INT_NAME From LOANS
		Where ID_CODE Like '%' + @searchString + '%'
		Union
		Select Distinct IDNO,ID_CODE,APPRS_NO,CUSTOMER,INT_NO,INT_NAME From LOANS
		Where APPRS_NO Like '%' + @searchString + '%'
		Union
		Select Distinct IDNO,ID_CODE,APPRS_NO,CUSTOMER,INT_NO,INT_NAME From LOANS
		Where CUSTOMER Like '%' + @searchString + '%'
		
														
		Select Zidno     'ACTUAL LOAN ID'  ,
		       Zid_Code  'CUSTOMER ID'  ,
		      -- Zapprs_No 'APPRAISAL NO',
		       ZCustomer 'NAME'
		From #SearchResults
	END
END
Closed because this post is not a question, or has not been phrased in a way that allows a reasonable answer to be provided. Reported by Peter Leow, Wes Aday on Friday, June 20, 2014 4:14pm
Posted 20-Jun-14 13:34pm
Closed 20-Jun-14 16:14pm
Peter Leow207.9K
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160927.1 | Last Updated 20 Jun 2014
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100