Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8005389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:13:02+00:00 2026-06-04T17:13:02+00:00

I have made webservice in asp.net using C# and MySQL. I want to return

  • 0

I have made webservice in asp.net using C# and MySQL. I want to return multiple values from this service. I am using the following code:

[WebMethod]
public string RegisterUserViaFacebook(string fbid, string fbmailid,string devicetype)  
{
    string success = "Already Registered";
    string id="", name="";

    if (!ExistsFBID(fbid))
    {
        name = GenerateUserName();

        string password = generatePassword(10);

        string insertUser = "Insert into tbl_userinfo(UserName,Password,Facebook_ID,Facebook_EmailID,DeviceType) values";
        insertUser += "( '" + name + "' ,'" + password + "','" + fbid + "','" + fbmailid + "','" + devicetype + "' )";
        con = new MySqlConnection(conString);
        con.Open();
        MySqlCommand cmd = new MySqlCommand(insertUser, con);
        success = cmd.ExecuteNonQuery().ToString();
        con.Close();

        string getID = "SELECT UserID from tbl_userinfo where UserName='" + name + "'  ";
        con = new MySqlConnection(conString);
        con.Open();
        MySqlCommand cmd1 = new MySqlCommand(getID, con);
        id = cmd1.ExecuteScalar().ToString();
        con.Close();


        if (Convert.ToInt16(success) > 0)
        {
            SendMail(fbmailid, name, password);
            success = "New User"  ;
        }
        else
            success = "Error in Insertion";
    }
    else
    {
        string getID1 = "SELECT UserID, UserName from tbl_userinfo where Facebook_ID='" + fbid + "' ";
        con = new MySqlConnection(conString);
        con.Open();
        MySqlCommand cmd2 = new MySqlCommand(getID1, con);
        MySqlDataReader info = cmd2.ExecuteReader();

        while (info.Read())
        {
            id = info.GetString(0);
            name = info.GetString(1);

        }
        con.Close();
    }

    string jsonString = JsonConvert.SerializeObject(success);
    String finalString = "{\"USER IS\":";
    finalString += jsonString;
    finalString += "}";

    string jsonString1 = JsonConvert.SerializeObject(id);
    String finalString1 =finalString + "{\"ID IS\":";
    finalString1 += jsonString1;
    finalString1 += "}" ;

    string jsonString2 = JsonConvert.SerializeObject(name);
    String finalString2 = finalString1 + "{\"NAME IS\":";
    finalString2 += jsonString2;
    finalString2 += "}";
    return finalString2;


 }

But it returns all values in single string. I want to return the values individually as Succeess, ID and Name.

How can I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:13:04+00:00Added an answer on June 4, 2026 at 5:13 pm

    Create a simple class to hold Succeess, id and name and return an serialized instance of it.

    public class RegistrationResult
    {
       public string Success { get; set; }
       public string Name { get; set; }
       public int Id { get; set; }
    }
    

    You could do this:

    var result = new RegistrationResult { Success = success, Name = name, Id = id} ;
    return JsonConvert.SerializeObject(success);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to webservice development. I have made webservice in asp.net using c#
I have made C# webservice in asp.net 2008 with 3.5 framework. I made this
I have made a website using( Asp.net, c# ) and its content in English
I have an asp.net web service project. This project contains a few classes declared
I have made asp.net webservice in C# to send mail on given mailid as
I have an asp.net mvc application, phpBB forum and asp.net webservice that I want
When making calls to a webservice from an asp.net web application, to avoid creating
I have an ASP.NET page that needs to make calls to multiple web services
We have a simple ASP.Net WCF Ajax enabled web service which is called via
I'm trying to call a WCF Webservice, from a dll I have made, running

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.