When i try to fire the autocomplete in my TextBox it return me this error:
localhost:44349 says:
{"Message":"
authentication failed","StackTrace":null,"ExceptionType":"System.InvalidOperationException"}
But my credentials are corrects, in fact i can connect directly using SSMS
I tried this:
These are the TextBox and his hidden field
<asp:TextBox runat="server" type="text" ID="searchInput" class="planningInput" placeholder="Cerca codice" />
<asp:HiddenField runat="server" ID="searchInputhf" />
This is my script:
<script type="text/javascript">
$(function () {
$("[id$=searchInput]").autocomplete({
source: function (request, response) {
$.ajax({
url: 'PlanningNAV.aspx/getAutocomplete',
data: "{ 'prefix': '" + request.term + "'}",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (data) {
response($.map(data.d, function (item) {
return {
value: item.split(' |')[0]
}
}))
},
error: function (response) {
alert(response.responseText);
},
failure: function (response) {
alert(response.responseText);
}
});
},
select: function (e, i) {
$("[id$=searchInput]").val(i.item.val);
},
minLength: 3
});
});
</script>
And in my code behind i got this:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string[] getAutocomplete(string prefix)
{
List<string> codice = new List<string>();
using (SqlConnection conn = new SqlConnection("Data Source = VMSRVDB01; Initial Catalog = ADIMPEX; Persist Security Info=True; User ID = user1; Password=User123; Integrated Security=True"))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "SELECT [Adimpex$Item].No_ FROM [Adimpex$Item] WHERE [Adimpex$Item].No_ LIKE ('%' + @SearchText + '%')";
cmd.Parameters.AddWithValue("", prefix.ToUpper());
cmd.Connection = conn;
conn.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
codice.Add(sdr.GetString(0));
}
}
}
}
return codice.ToArray();
}
but when i type the third letter i got that authentication error.
It seems it's not passing the User ID and Password values, what should i do?