Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using System.Web.Script.Serialization;
using MySql.Data.MySqlClient;
using System.Data;


 [WebMethod]
    public loginfields[] login_form_validation2(string username, string password)
    {
        con = c.get_connectionstring();
        loginfields l = new loginfields();
        con.Open();
        var samples = new List<loginfields>();
        cmd = new MySqlCommand("select *from login where username='" + username + "' and password='" + password + "'", con);
        MySqlDataReader dr = cmd.ExecuteReader();
        // IDictionary<string,string> dict = new Dictionary<string,string>();
        l.ids = "1";
        l.username = "eswar";
        l.status = "1";
        samples.Add(l);
       // dr.Read();
        //loginfield[0].ids = dr.GetString["id"];

        return samples.ToArray();
    }

    public loginvalidation()
    {
        //
        // TODO: Add constructor logic here
        //
    }
}
public class loginfields
{
    public string ids { get; set; }
    public string username { get; set; }
    public string status { get; set; }
}


My Actual output from my webservice, I need to print those values from my client windows form text box, Can anyone help ??

-<arrayofloginfields xmlns="http://tempuri.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">


-<loginfields>

<ids>1</ids>

<username>eswar</username>

<status>1</status>

</loginfields>

</arrayofloginfields>
Posted
Updated 23-Aug-15 8:31am
v3

1 solution

add service reference to your winform application, then you can create instance of service client class and call the service method with parameters.
you can use the returned value of the service method to display.
check
How to use a Web Service in Windows Form Application[^]
 
Share this answer
 
Comments
Eswar1988 23-Aug-15 22:49pm    
Hi,

Thanks for your reply, But i already did that, problem is my webservice returning output like xml format, How can i read those values ??


My client app code :

private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
MyObject arr = new MyObject();
arr=valid.login_form_validation("eswar","eswar");

}

}
public class MyObject {
public string ids { get; set; }
public string username { get; set; }
public string status { get; set; }
}

Getting the following error :

Error 5 Cannot implicitly convert type 'object' to 'WindowsFormsApplication1.MyObject'. An explicit conversion exists (are you missing a cast?) e:\messenger\messenger\windowsformsapplication1\buddywindow.cs 104 16 WindowsFormsApplication1
DamithSL 23-Aug-15 23:24pm    
can you update the question with login_form_validation code?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900