0

我的页面上有一个自动完成扩展器,可以根据姓氏搜索数据库。出于某种原因,在搜索应该返回 1564 结果的“Smith”时没有返回任何内容?当我搜索其他名称时,它可以正常工作“琼斯”等。我认为“史密斯”的行数最多,并且有限制或什么?有任何想法吗?

 <asp:TextBox ID="DoctorNameTextBox" runat="server" Height="24px" Width="739px" 
            Font-Size="Small"></asp:TextBox>
        <asp:AutoCompleteExtender ID="AutoCompleteExtender" runat="server" 
    DelimiterCharacters="" Enabled="True" ServicePath="AutoComplete.asmx" 
            ServiceMethod="GetCompletionList" TargetControlID="DoctorNameTextBox" 
    MinimumPrefixLength="2" UseContextKey="true" ContextKey="StateDropDown"
            CompletionListElementID="autocompleteDropDownPanel" 
            onclientitemselected="getSelected" CompletionSetCount="20" 
            ShowOnlyCurrentWordInCompletionListItem="True">

Public Function GetCompletionList(prefixText As String, count As Integer, ByVal contextKey As String) As String()
    Try
        Dim Con As SqlConnection
        Dim cmd As SqlCommand
        Con = New SqlConnection
        Dim test As String
        test = contextKey
        Con.ConnectionString = ""
        Con.Open()

        cmd = New SqlCommand
        cmd.Connection = Con
        cmd.CommandText = "SELECT NPI, [Entity Type Code], [Provider Last Name (Legal Name)], [Provider First Name],[Provider First Line Business Mailing Address], [Provider Business Mailing Address City Name], [Provider Business Mailing Address State Name], [Provider Business Mailing Address Postal Code] FROM NPIData WHERE   ([Provider Business Mailing Address State Name] = @State) AND ([Provider Last Name (Legal Name)] LIKE N'%' + @Provider + N'%') ORDER BY [Provider First Name]"
        cmd.Parameters.AddWithValue("@Provider", prefixText)
        cmd.Parameters.AddWithValue("@State", contextKey)
        Dim customers As List(Of String) = New List(Of String)
        Dim reader As SqlDataReader = cmd.ExecuteReader()


        While reader.Read
            customers.Add(reader("Provider Last Name (Legal Name)").ToString + ", " + reader("Provider First Name").ToString + "   " + reader("Provider First Line Business Mailing Address").ToString + "  " + reader("Provider Business Mailing Address City Name").ToString + ", " + reader("Provider Business Mailing Address State Name").ToString + "  " + reader("Provider Business Mailing Address Postal Code").ToString + "  " + reader("NPI").ToString)

        End While


        Con.Close()

        Return customers.ToArray
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try

End Function
4

1 回答 1

2

当 Web 服务返回的列表超过最大 jsonSerialization 限制 102400(字符串长度)时,会AutoCompleteExtender静默失败。“解决”这个问题(虽然不实用)的一种方法是增加 web.config 中的值,如下所示:

确保您的 sectionGroup 部分中有此部分。如果没有,请添加它。

<sectionGroup name="system.web.extensions" type="System.Web.Extensions">
    <sectionGroup name="scripting" type="System.Web.Extensions">
         <sectionGroup name="webServices" type="System.Web.Extensions">
                  <section name="jsonSerialization" type="System.Web.Extensions"/>
          </sectionGroup>
    </sectionGroup>
</sectionGroup> 

然后设置值:

<configuration> 
   <system.web.extensions>
       <scripting>
           <webServices>
               <jsonSerialization maxJsonLength="50000000"/>
           </webServices>
       </scripting>
   </system.web.extensions>
</configuration> 

请参阅其他答案。

于 2013-07-31T20:04:35.677 回答