- Back to Home »
- Windows store apps C#/XAML »
- C# Windows store app code to login by checking data in sql server database using webservice
Posted by :
Sudhir Chekuri
Wednesday, 6 November 2013
C# code in Windows store app to login into app by checking data in sql server database using webservice
private async void btn_login_Click_1(object sender, RoutedEventArgs e)
{
ComplaintServiceReference1.complaintSoapClient obj = new complaintSoapClient();
var ds= await obj.loginAsync(txt_name.Text, Convert.ToString(txt_password.Text));
if (ds.Body.loginResult > 0)
{
this.Frame.Navigate(typeof(complaint));
}
else
{
txt_name.Text = "";
txt_password.Text = "";
}
}
webservice:
[WebMethod]
public int login(string name,string password)
{
string s = "select name,passward from registration where name='"+name+"'and passward='"+password+"'";
SqlConnection con = new SqlConnection("Data Source=FS8HH1S\\SQLEXPRESS;Initial Catalog=grievancedata;Integrated Security=True");
//SqlCommand cmd = new SqlCommand(s, con);
SqlDataAdapter da = new SqlDataAdapter(s,con);
DataSet ds = new DataSet();
da.Fill(ds);
int count=ds.Tables[0].Rows.Count;
return count;
}