Web Service code not returning array of String

前端 未结 3 1152

I want to return an array of Strings in the form \"abc#xyz#ghi#tru\" (where # is delimiter) from my web service method . However i m not able to do it . Here is my current web s

3条回答
  •  心在旅途
    2021-01-26 18:33

    First, your query returns only number instead of set of rows. So you should use sql like this:

    select name from names
    

    Second, to return array you could use List instead of pre-defined arrays: I would be use the following approach:

    var result = new List();
    while(myReader.Read())
    {
      result.Add(reader["name"].ToString() + "#");
    }
    
    return result.ToArray();
    

    Or if you want to return a string:

    return string.Join("#", result.ToArray())
    

提交回复
热议问题