예제 #1
0
        private void TestDb()
        {
            try
            {
                db.CreateTable <DemoUser>();
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, "Create: " + ex.ToString(), ToastLength.Short).Show();
            }

            DemoUser user = new DemoUser();

            user.UserName = "******";
            user.Password = "******";

            try
            {
                db.Insert(user);
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, "Insert: " + ex.ToString(), ToastLength.Short).Show();
            }

            Toast.MakeText(this, "New User Added", ToastLength.Short).Show();
        }
        private void InsertNewUser(string newUserName, string newPassword)
        {
            try
            {
                db.CreateTable <DemoUser>();
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, "Create: " + ex.ToString(), ToastLength.Short).Show();
            }

            DemoUser user = new DemoUser();

            user.UserName = newUserName;
            user.Password = newPassword;

            try
            {
                db.Insert(user);
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, "Insert: " + ex.ToString(), ToastLength.Short).Show();
            }

            Toast.MakeText(this, "New user " + newUserName + " successfully added.  " +
                           "Total rows now: " + GetUserRowCount().ToString(), ToastLength.Short).Show();
        }