Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

SQLite Insert with special characters

$
0
0

Hi ,

We are using SQlite library version 3.1.1 in Xamarin forms. Oure insert query fails when we we try to save user's password which contain special characters.
It works perfectly for string without special characters . However if the string is like "••••••••"then it fails with Unrecognized token error.

/// Insert user details at login, to maintain user session till logout.
///
///

User list.
public void InsertUserDetails(List userList)
{
lock (locker)
{
try
{
foreach (UserDetail user in userList)
{
int id = user.ID;
string query;
                    query = "Insert into UserDetail(ID,Title,FirstName,SurName,Email,Password,BranchKey,Phone_eve,Phone_day,Phone_Mobile,EmailOk,SMSOk,SnailOk,Banned,Suspended,Cancelled,TimeZone) " +
                        "values ('" + user.ID +
                                          "','" + user.Title +
                                          "','" + user.FirstName +
                                          "','" + user.SurName +
                                          "','" + user.Email +
                                          "','" + user.Password +
                                          "','" + user.BranchKey +
                                          "','" + user.Phone_eve +
                                          "','" + user.Phone_day +
                                          "','" + user.Phone_Mobile +
                                          "','" + user.EmailOk +
                                          "','" + user.SMSOk +
                                          "','" + user.SnailOk +
                                          "','" + user.Banned +
                                          "','" + user.Suspended +
                                          "','" + user.Cancelled +
                                          "','" + user.TimeZone +
                                          "' ) ";


                    database.Query<UserDetail>(query);
                }
            }
            catch (SQLiteException ex)
            {
                int k = 0;
            }
        }
    }

Our UserDetail class is as follows-:
public class UserDetail
{
public Int32 ID { get; set; }

    public string Title { get; set; }

    public string FirstName { get; set; }

    public string SurName { get; set; }

    public string Email { get; set; }

    public string Password { get; set; }

    public string BranchKey { get; set; }

    public string Phone_eve{ get; set; }

    public string Phone_day{get;set;}

    public string Phone_Mobile { get; set; }

    public bool EmailOk { get; set; }

    public bool SMSOk { get; set; }

    public bool SnailOk{ get; set; }

    public bool Banned { get; set; }

    public  bool Suspended { get; set; }

    public bool Cancelled { get; set; }

    public string TimeZone { get; set; }

}

Viewing all articles
Browse latest Browse all 204402


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>