AutoCompleteExtender won't work when receiving list from DB

  • Thread starter Thread starter rote
  • Start date Start date
R

rote

When i type in a word the webservice doesn't retrieve anyhthing its just
blank any ideas what 'm doing wrong?

My Snippet code below.
In my store proc i have like below :
select firstname from Employee where firstname like @term+'%'

and when i do sp_GetEmployeeByName 'somefirstname '
I recieve data..

<toolkit:AutoCompleteExtender ID="AutoCompleteSearch"
MinimumPrefixLength="1" runat="server" TargetControlID="SearchText"
ServicePath="myserv.asmx" ServiceMethod="FirstNameNumLookup" />

[WebMethod]
public string[] FirstNameNumLookup(string prefixText, int count)
{

SqlConnection conn = new SqlConnection("Some Conn");

SqlCommand command = null;
command = new SqlCommand("sp_GetEmployeeByName", conn);

DataTable dt = new DataTable();
SqlDataAdapter adapter = null;

try
{
command.Parameters.Add("@prefixText", SqlDbType.NVarChar,
50).Value = prefixText;
adapter = new SqlDataAdapter(command);
adapter.Fill(dt);
}
catch (Exception e)
{
//handle exception

}
finally
{
if (adapter != null)
{
adapter.Dispose();
}

if (command != null)
{
command.Dispose();
}

if (conn != null)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn = null;
}

}
string[] items = new string[dt.Rows.Count];
int i = 0;

foreach (DataRow dr in dt.Rows)
{

items.SetValue(dr["firstname"].ToString(), i);

i++;
}

return items;
}
 
Salutations,

When you test your web service, are you seeing data returned? If so, then
you should probably walk through the instructions at
http://www.asp.net/ajax/documentation/live/tutorials/ExposingWebServicesToAJAXTutorial.aspx
in order to make sure that you've got your ScriptManager set up right. Or,
if you'll post the code in question, we can look at it and tell you whats
up.

By the way, it doesn't look like you ever set CommandType to
StoredProcedure, that could be the source of your woes...

Regards,
Bryan Porter
http://www.bryanporter.com/

"What A Horrible Night To Have A Curse!"
 
Back
Top