Click here to Skip to main content
15,912,507 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi all

i designed a web site and put a search box to search site content
using stored procedure and its work well locally before upload it to the web server
its not worked

why doesn't work on web server ??
please help me

nothing works today :(


XML
i used a stored procedure to search all data in my tables as:

USE [PROC1]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:      <author,,name>
-- Create date: <create>
-- Description: &lt;description,,&gt;
-- =============================================
ALTER PROCEDURE [dbo].[sp_SearchArPages]
    @prmWordSearch nvarchar(150)
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    DECLARE @sqlart nvarchar(MAX)




SET @sqlart ='select ID,ArticleTitle,ArticleText from Articles where ArticleTitle like ''%' + @prmWordSearch + '%'' OR ' + ' ArticleText like ''%' + @prmWordSearch  + '%'''



    EXEC sp_executesql @sqlart

END

'''''''''''''''''''''''
my code in aspx.vb page:
<pre lang="vb">If Request.QueryString(&quot;srcKeyWord&quot;) &lt;&gt; &quot;&quot; Then
           lblcontent.Text = cls.searchOnArPages(Request.QueryString(&quot;srcKeyWord&quot;))

 End If</pre>

''''''''''''''''''

searchOnArPages function:

<pre lang="vb">Function searchOnArPages(ByVal strKeyWord As String) As String


        Dim strResults As String = &quot;&quot;

        Dim sqlAdp As New SqlDataAdapter
        Dim sqlCmd As New SqlCommand
        Dim ds As New DataSet


        sqlCmd.CommandText = &quot;sp_SearchArPages&quot;
        sqlCmd.CommandType = CommandType.StoredProcedure
        sqlCmd.Connection = sqlCN
        sqlCmd.Parameters.Add(New SqlParameter(&quot;@prmWordSearch&quot;, SqlDbType.NVarChar)).Value = strKeyWord

        sqlAdp.SelectCommand = sqlCmd
        sqlAdp.Fill(ds)

        Dim intResultsCount As Integer = CInt(ds.Tables(0).Rows.Count + ds.Tables(1).Rows.Count + ds.Tables(2).Rows.Count + ds.Tables(3).Rows.Count + ds.Tables(4).Rows.Count + ds.Tables(5).Rows.Count + ds.Tables(6).Rows.Count + ds.Tables(7).Rows.Count)

        If intResultsCount &gt; 0 Then
            For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
                strResults = strResults &amp; &quot;&lt;tr&gt;&lt;td&gt;&lt;a class='cssSRC' href='ARCont.aspx?ArticleId=&quot; &amp; ds.Tables(0).Rows(i).Item(0) &amp; &quot;'&gt;&quot; &amp; ds.Tables(0).Rows(i).Item(1) &amp; &quot;: &quot; &amp; ClearHTMLTags(Left(ds.Tables(0).Rows(i).Item(2), 100) &amp; &quot;....Read more&quot;, 0) &amp; &quot;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&quot;
            Next
 Else
            strResults = strResults.Insert(0, "<table boder="0" width="70%"><tr><td><i> no results <font style="font-size:12px;color:red;"> ' " & strKeyWord & " '</font> please try again.</i></td></tr>")
            strResults = strResults & "</table>"
        End If
        Return strResults
    End Function</pre></create>
Posted
Updated 30-Apr-14 17:40pm
v2
Comments
Put try catch blocks in your code. Handle exceptions. Then you might get to know the issue.
[no name] 26-Apr-14 14:13pm    
Well we do not have access to your server or your code and we would have no idea what you think "doesn't work" actually means.
Bh@gyesh 1-May-14 3:23am    
Please specify your error. "doesn't work" is not enough.
Sarah MQ 1-May-14 3:34am    
thanks or your response <br><br>
when i press the search button the result "please try again" that means there is no keywork like the word i search for it <br><br>
but indeed there is a keyword exist in my table <br><br>
and it appears when i press the button in local host when i test the web page before upload the pages to the web server

i make a test on the English keywords and its return correct values but the problem is in the Arabic keyword
Prasad Avunoori 1-May-14 5:39am    
Hi Sarah,

What is the collation you had used for that specific column in Database table?

1 solution

thanks all for your response and suggestions
i find the problem
and its simply was in the "N" character !!
when i insert this 'N' before each key word in the stored procedure
its work
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900