[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
SqlConnection Con;
SqlCommand Cmd;
string[] items;
[WebMethod]
public string[] GetStateName(string prefixText)
{
try
{
Con = new SqlConnection("Your Connection string");
Con.Open();
Cmd = new SqlCommand("sp_getValue", Con);
Cmd.CommandType = CommandType.StoredProcedure;
Cmd.Parameters.AddWithValue("@prefixText", prefixText);
SqlDataAdapter da = new SqlDataAdapter(Cmd);
DataTable dt = new DataTable();
da.Fill(dt);
items = new string[dt.Rows.Count];
int i = 0;
foreach (DataRow dr in dt.Rows)
{
items.SetValue(dr["StateName"].ToString(), i);
i++;
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
Con.Close();
}
return items;
}
}