AutoCompleteExtender won't work when receiving list from DB

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;
}
 
B

Bryan Porter

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!"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top