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