I have a problem , when user enter the input, where should I save the data? I'm already connect the sqlite but I'm not sure how to save the input.Let focus on how to create login page. I have a connection.xaml.cs and login.xaml.cs. So this is my problem. Below is the connection.xaml.cs.If possible, give me a link that i can refer and study. I am beginner in sqlite. Thank You.
SQLiteConnection sqlite_conn;
SQLiteCommand sqlite_cmd;
SQLiteDataReader sqlite_datareader;
sqlite_conn = new SQLiteConnection("Data Source=database.db;Version=3;New=True;Compress=True;");
sqlite_conn.Open();
sqlite_cmd = sqlite_conn.CreateCommand();
sqlite_cmd.CommandText = "CREATE TABLE Login (id integer primary key, username varchar(50),password varchar(50));";
sqlite_cmd.ExecuteNonQuery();
sqlite_cmd.CommandText = "INSERT INTO Login (id,username,password) VALUES (111043, 'zakira' ,'abc123');";
sqlite_cmd.ExecuteNonQuery();
sqlite_cmd.CommandText = "SELECT * FROM Login";
sqlite_datareader = sqlite_cmd.ExecuteReader();
while (sqlite_datareader.Read())
{
string Myreader = sqlite_datareader.GetString(0);
string Myreader2 = sqlite_datareader.GetString(1);
string Myreader3 = sqlite_datareader.GetString(2);
MessageBox.Show(Myreader + " " + Myreader2 + " " + Myreader3);
}
sqlite_conn.Close();
}
Below is my Login.cs.xaml (login page). This is what i'm already done
private void button1_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("Dalam Login button");
string query = "select from (Login) where password='" + textBox2.Text + "'";
ExecuteQuery(query);
SQLiteDataReader dr = sqlite_cmd.ExecuteReader();
int count = 0;
while (dr.Read())
{
count++;
}
if (count == 1)
{
MessageBox.Show("Logged In ");
}
else
MessageBox.Show("Wrong Password :(");
}
private void textBox2_TextChanged(object sender, TextChangedEventArgs e)
{
var textBox = sender as TextBox;
}
}