c# - Webservice Returns Data All On One Line -


Then I have a basic web service that is grabbing data from an MSSQL database, it works because it's a SQL connection and It is considered in the case of questions, but I would like to know whether it is possible to show the figures a little more beautiful. My goal is to return a name to each line, but the web service only leaves all in between the string tags and all on one line. I am very new to C # and ASP.Net and am surprised that I have made it so far. If possible, I have to format the data in a more pleasant way.

This is my code

  Namespace Customer Service {/// & lt; Summary & gt; Summary descriptions for /// service details & lt; / Summary & gt; [WebServices (namespace = "http://tempuri.org/")] [webssebibing (conferfooto = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem (false)] // Allow this web service to call scripts For, using the ASP.NET AJAX, delete the following line // [System.Web.Script.Services.ScriptService] Public Class Service1: System.Web.Services.WebService {[WebMethod] // to get names New webmooth name for public string getNames () {int size = DataHelper.name () .ount (); String [] name = new string [size]; Name = DataHelper.name (); Back to string (name); } // passed the array and convert a single string to public string for string (string [] names {int size = names.Count (); string [] name array = new string [size]; name array = name; string (Int x = 0; x & lt; size; x ++) for output = ""; {output = output = "\ n" + name array [x];} return output;}}}   

and then the DataHelper service:

 using the  system; using System.Collections.Generic; using System.Linq; using System.Web; Use System.Data Using the System.Data.SqlClient; Name Location Customer Service {PUBLIC CLASS DataHelper {// CUSTOMER DB} Make a method to get names from public static strings [] Name () {string currentName = ""; string [] Name = new string [100]; double check ball; double saving ball; double CDBL; double mm ball; // make connection SqlConnection conn = new SqlConnection (@ "data source = STE2074; initial catalog = ATMWeb; Information = true; user id = ss P; password = stp48329 "); // Create command to get the name string sqlString = "SELECT * FROM tblUsers"; SqlCommand CMD = New SqlCommand (sqlString, conn); conn.Open (); Int x = 0; {Reader.Read ()} {currentName = reader ["firstname"]) when using (SqlDataReader Reader = cmd.ExecuteReader ()). ToString (); Name [x] = current name; X ++; } // close connection conn.Close (); Reader.Close (); Name back; }}}   

And this is the end result:

    

I want a new line after every name ... is this possible?

Create a square and return it

  public class MyOldStringNames { Property String NameHolder {get; Set; }} End class list & lt; MyOldStringNames & gt; MyListOfOldStringNames = New list & lt; MyOldStringNames & gt; (); MyOldStringNames myItemToAdd = New MyOldStringNames (for names) in each item {NameHolder = item.toString ()}; myListOfOldStringNames.add (myItemToAdd); Last return myListOfOldStringNames;   

Of course your method will be the same. : Public listing & lt; MyOldStringNames & gt; GetNames () {int size = DataHelper.name (). Calculation (); String [] name = new string [size]; Name = DataHelper.name (); // Data returns to the above // ​​content as above; }

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -