Hi,
Is your web service working fine.
You have to uncomment this
 [System.Web.Script.Services.ScriptService]
If still not works tell what the error comes.

Pratiksha



On Tue, Mar 30, 2010 at 8:49 PM, Mos <[email protected]> wrote:

> Folks I am having difficulty with an autocomplete capability
>
> Searching a SQL 2008 with 80,000 records
>
> ===============Default.aspx Code==============
>
> <%@ Page language="C#"%>
>
> <%@ Import Namespace="System.Data.SqlClient" %>
>
> <%@ Register Assembly="AjaxControlToolkit"
> Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
>
> <html>
>
> <head>
>
> <title id="titl" runat="server">AutoComplete Feature</title>
>
> </head>
>
> <body onload="document.forms[0].txtCliente.focus()">
>
> <div align="center">
>
> <form id="Form1" class=frm runat="server">
>
> <asp:ScriptManager ID="ScriptManager1" runat="server"
> EnableScriptGlobalization="True"
>
> EnableScriptLocalization="true">
>
> </asp:ScriptManager>
>
> <table border=0>
>
> <tr>
>
> <td>User:</td>
>
> <td>
>
> <asp:TextBox ID="txtCliente" runat="server" Width="140px"
> ToolTip="Type a few letters"></asp:TextBox>
>
> <cc1:AutoCompleteExtender ID="txtCliente_AutoCompleteExtender"
> runat="server" DelimiterCharacters=""
>
> Enabled="True" ServicePath="AutoComplete.asmx"
> ServiceMethod="GetMedicationList"
>
> TargetControlID="txtCliente" EnableCaching="true"
> MinimumPrefixLength="1" CompletionInterval="150">
>
> </cc1:AutoCompleteExtender>
>
> </td>
>
> </tr>
>
> </table>
>
> </form>
>
> </div>
>
> </body>
>
> </html>
>
> ===============AutoComplete.asmx Code===============
>
> namespace AJAXAutoComplete
>
> {
>
> /// <summary>
>
> /// Summary description for AutoComplete
>
> /// </summary>
>
> [WebService(Namespace = "http://tempuri.org/";)]
>
> [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
>
> [ToolboxItem(false)]
>
> // To allow this Web Service to be called from script, using 
> ASP.NET<http://asp.net/>
> AJAX, uncomment the following line.
>
> // [System.Web.Script.Services.ScriptService]
>
> public class AutoComplete : System.Web.Services.WebService
>
> {
>
> [WebMethod]
>
> public string HelloWorld()
>
> {
>
> return "Hello World";
>
> }
>
> [WebMethod]
>
> public string[] GetMedicationList(string prefixText)
>
> {
>
> DataSet dtst = new DataSet();
>
> string mConnString =
> ConfigurationManager.ConnectionStrings["Nova"].ConnectionString;
>
> SqlConnection wCnn = new SqlConnection(mConnString);
>
> //string strSql = "SELECT farmacia FROM Sucursal WHERE farmacia LIKE
> '" + prefixText + "%' ";
>
> string strSql = "SELECT MedicationName FROM DOCUMENTS_MEDICATIONS
> WHERE MedicationName LIKE '" + prefixText + "%' ";
>
> SqlCommand sqlComd = new SqlCommand(strSql, wCnn);
>
> wCnn.Open();
>
> SqlDataAdapter sqlAdpt = new SqlDataAdapter();
>
> sqlAdpt.SelectCommand = sqlComd;
>
> sqlAdpt.Fill(dtst);
>
> string[] cntName = new string[dtst.Tables[0].Rows.Count];
>
> int i = 0;
>
> try
>
> {
>
> foreach (DataRow rdr in dtst.Tables[0].Rows)
>
> {
>
> cntName.SetValue(rdr["MedicationName"].ToString(), i);
>
> i++;
>
> }
>
> }
>
> catch (SqlException sqlEx)
>
> {
>
> Console.WriteLine(sqlEx.ToString());
>
> }
>
> finally
>
> {
>
> wCnn.Close();
>
> }
>
> return cntName;
>
> }
>
> }
>
> }
>
> ===========Web.Config===============
>
> <connectionStrings>
>
> <add name="Nova" connectionString="Data Source=xxxx;Initial
> Catalog=BTNET;Persist Security Info=True;User
> ID=btnetsa;Password=password;" providerName="System.Data.SqlClient"/>
>
> </connectionStrings>
>
>
> --
> To unsubscribe, reply using "remove me" as the subject.
>

Reply via email to