Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
in wcf i am using this code
C#
public List<customer> login(string salesmanname, string usercode)
{
    List<customer> customers = new List<customer>();
    con.Open();
    using (SqlCommand cmd = new SqlCommand("Select Id, CompanyRefId from SalesMan where salesmanname=@salesmanname and code=@usercode", con))
    {
        cmd.Parameters.AddWithValue("@salesmanname", salesmanname);
        cmd.Parameters.AddWithValue("@usercode", usercode);
        using (SqlDataReader reader = cmd.ExecuteReader())
        {
            while (reader.Read())
            {
                customer c1 = new customer();
                c1.id = (int)reader["Id"];
                c1.companyrefid = (Guid)reader["CompanyRefId"];
                customers.Add(c1);

            }
            return customers;
        }

    }
}


in windows phone i am using this code
C#
string username = salesmannames.SelectedItem.ToString();
               string password = textBox1.Text.ToString();
                proxy.loginAsync(username, password);
                proxy.loginCompleted += new EventHandler<loginCompletedEventArgs>(loginfn);

void loginfn(object sender, loginCompletedEventArgs e)
       {
           if (e.Result != null)
           {
               customer ad = new customer();


               NavigationService.Navigate(new Uri("/customernames.xaml", UriKind.Relative));
           }
       }


i want to set id = 1
and companyrefid= 13444;
how to do that in windows phone code ?
Posted
Updated 31-May-14 22:06pm
v3

1 solution

There can be different ways, but first of all, look at http://msdn.microsoft.com/en-us/library/ms733127%28v=vs.110%29.aspx[^].

I mentioned Data Contracts because you asked specifically on data serialization, but that's not all. Anyway, essentially, there is no such thing as "from WCF to Windows Phone", because you can use WCF on Windows Phone, so you can use service contracts and everything. Please see:
http://blogs.msdn.com/b/andypennell/archive/2010/09/20/using-wcf-on-windows-phone-7-walk-through.aspx[^].

—SA
 
Share this answer
 
Comments
Nandhini Devi 2-Jun-14 0:45am    
i am getting error like cannot convert obsevable collection to generic
void loginfn(object sender, loginCompletedEventArgs e)
{
if (e.Result != null)
{
customer ad = e.result;


NavigationService.Navigate(new Uri("/customernames.xaml", UriKind.Relative));
}
}

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