Skip to content
Loading
Search Record functionality using ajax is not working?
 
  1.        [WebMethod] //for retrieve the data  
  2.           
  3.         public static string GetData()  
  4.         {  
  5.             cn.Open();  
  6.             string data = "";  
  7.             SqlCommand cmd = new SqlCommand("selectstud", cn);  
  8.             cmd.CommandType = CommandType.StoredProcedure;  
  9.             SqlDataAdapter da = new SqlDataAdapter(cmd);  
  10.             DataSet ds = new DataSet();  
  11.             da.Fill(ds);  
  12.   
  13.             if (ds.Tables[0].Rows.Count > 0)  
  14.             {  
  15.                 data = JsonConvert.SerializeObject(ds.Tables[0]);  
  16.             }  
  17.             cn.Close();  
  18.   
  19.             return data;  
  20.   
  21.         }  
  22.   
  23.         [WebMethod]  
  24.         public static void search(string studname)                
  25.         {  
  26.             cn.Open();  
  27.   
  28.             SqlCommand cmd = new SqlCommand("SELECT studname FROM tblstud WHERE studname LIKE '%'+@studname+'%'", cn);  
  29.   
  30.             cmd.Parameters.AddWithValue("@studname", studname);  
  31.   
  32.             SqlDataReader reader = cmd.ExecuteReader();  
  33.   
  34.             if (reader.HasRows)  
  35.             {  
  36.                 while (reader.Read())  
  37.                 {  
  38.                     Console.WriteLine("{1}",reader.GetString(1));  
  39.                 }  
  40.             }  
  41.             else  
  42.             {  
  43.                 Console.WriteLine("No rows found.");  
  44.             }  
  45.   
  46.             reader.Close();  
  47.         }  
 
 
 
 
 
see my browser log which place I m going to wrong?
which place I m not correct?help?
 

19 Replies

Know the answer? Post it — somebody with the same question will find it here.