Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is it possible to implement the autocomplete textbox using sqldatasource?
In every keypress,the data should be called from database via sqldatasource.
I have tried to use WebService method to call database many times and methods,but it doesnt work.
Posted
Comments
Sandeep Mewara 12-Aug-10 15:13pm    
Question from one of the member: Are you using asp.net or a stand alone app?

1 solution

Check this code...

[WebMethod]
public string[] GetWellInfo(string prefixText)
{

string sql = "Server=NAME;Data Source=NAME;User ID=UserName;Password=APssword";
OracleConnection Oracon = new OracleConnection(sql);
OracleDataAdapter dataAdapter = new OracleDataAdapter("select * from TableName where Column Name like '%" + prefixText.ToUpper() + "%'", Oracon);
dataAdapter.SelectCommand.Parameters.Add("@prefixText", OracleType.VarChar, 100, "ColumnName");
DataTable dt = new DataTable();
dataAdapter.Fill(dt);

string[] items = new string[dt.Rows.Count];
int i = 0;
foreach (DataRow dr in dt.Rows)
{
items.SetValue(dr["ColumnName"].ToString(), i);
i++;
}
return items;
}

This would work,,
If stuck up at any point, do let me know.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900