[WebMethod]
public List< string> HelloWorld(string prefixText)
{
SqlConnection con = new SqlConnection("Database=bluedd;Server=(local);Integrated Security=SSPI");
con.Open();
SqlCommand cmd = new SqlCommand("select user_master.first_name from user_master where first_name like @Name+'%'", con);
cmd.Parameters.AddWithValue("@Name", prefixText);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
List<string> CountryNames = new List<string>();
for (int i = 0; i < dt.Rows.Count; i++)
{
CountryNames.Add(dt.Rows[i].ToString());
}
return CountryNames;
}
This code returns System.Data.DataRow is there any casting problem
I am very new in s/w Development, any help will be appreciated
Your code is returning the data row. To return the column you would do something like
I think what you want is to replace your for loop with this.