tags:

views:

23

answers:

1

There was an error parsing the query. [ Token line number = 1,Token line offset = 15,Token in error = User ]

how do i fix this?

im querying it "SELECT * FROM User", and then i get my error, the code im using is this:

public static List<User> GetUsers()
            {
                List<User> users = new List<User>();
                using (SqlCeConnection con = new SqlCeConnection(Properties.Settings.Default.DatabaseConnection))
                {
                    con.Open();
                    using (SqlCeCommand command = new SqlCeCommand("SELECT * FROM " + TABLE, con))
                    {
                        SqlCeDataReader reader = command.ExecuteReader();
                        while (reader.Read())
                        {
                            int id = reader.GetInt32(0);
                            string user = reader.GetString(1);
                            User usr = null;
                            using (MemoryStream s = new MemoryStream())
                            {
                                NetDataContractSerializer serializer = new NetDataContractSerializer();
                                s.Write(ASCIIEncoding.ASCII.GetBytes(user.ToCharArray()), 0, user.Length);
                                s.Position = 0;
                                usr = (User)serializer.Deserialize(s);
                            }
                        }
                    }
                }
                return users;
            }

Note: i also get this error trying to add information.

+1  A: 

It looks like the token 'User' is not being understood. Just a guess (I don't have a SqlCE to test on) try "quoting" the table name with square brackets:

"SELECT * FROM [User]"
Mark Byers
thankyou soo much! i would have never thought of that..
Tommy