The following code inserts the values successfully to local db. I cannot retrieve them and compare them login to next page
public class Mytable
{
public string Name { get; set; }
public string Password { get; set; }
public string Gender { get; set; }
public string State { get; set; }
}
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
var dbpath = ApplicationData.Current.LocalFolder.Path + "/Mydb1.db";
var con = new SQLiteAsyncConnection(dbpath);
await con.CreateTableAsync<Mytable>();
}
private async void Button_Click(object sender, RoutedEventArgs e)
{
var dbpath = ApplicationData.Current.LocalFolder.Path + "/Mydb1.db";
var con = new SQLiteAsyncConnection(dbpath);
Mytable m = new Mytable();
m.Name = text_reg.Text;
m.Password = text_password.Password;
string rd = "";
if(radio_male.IsChecked==true)
{
rd = "Male";
}
else
{
rd = "Female";
}
m.Gender = rd;
m.State = ((ComboBoxItem)combo_box.SelectedItem).Content.ToString();
await con.InsertAsync(m);
MessageDialog md = new MessageDialog("success");
await md.ShowAsync();
}
private async void Button_Click_1(object sender, RoutedEventArgs e)
{
var dbpath = ApplicationData.Current.LocalFolder.Path + "/Mydb1.db";
var con = new SQLiteAsyncConnection(dbpath);
List<Mytable> mylist= await con.QueryAsync<Mytable>("select * from Mytable where Name='" + text_reg.Text + "' and Password='" + text_password.Password + "'");
foreach(Mytable r in mylist)
{
if (r.Name == text_reg.Text && r.Password == text_password.Password)
{
this.Frame.Navigate(typeof(Blankpage1));
}
else
{
var messagedialog = new MessageDialog("Unsuccessful").ShowAsync();
}
}
}
I cannot compare and retrieve the inserted values. Please help me to make my login successful
Aucun commentaire:
Enregistrer un commentaire