这是我的功能:
<script type="text/javascript">
$(document).ready(function () {
SearchText();
});
function SearchText() {
$(".autosuggest").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Default.aspx/GetAutoCompleteData",
data: "{'name':'" + document.getElementById('txtSearch').value + "'}",
dataType: "json",
success: function (data) {
response(data.d);
},
error: function (result) {
alert("Error");
}
});
}
});
}
</script>
这是我的代码:
[WebMethod]
public static List<string> GetAutoCompleteData(string name)
{
OracleConnection con = new OracleConnection("Data Source=Client;User ID=cli; Password=cli123");
List<string> result = new List<string>();
con.Open();
OracleCommand cmd = new OracleCommand("SELECT CLIENT_NO FROM SC_CLIENT WHERE CLIENT_NO LIKE :SearchText+'%'", con);
cmd.Parameters.AddWithValue(":SearchText", name);
OracleDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
result.Add(dr["CLIENT_NO"].ToString());
}
return result;
}
但这是给出这样的错误消息“ORA-01722:无效号码”。我该如何解决这个问题?