Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8024567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:54:11+00:00 2026-06-04T22:54:11+00:00

I am writing a program in C# using Visual Studio 2010 and gets an

  • 0

I am writing a program in C# using Visual Studio 2010 and gets an error when retrieving data from a .sdf file.

private void BasicSearch_button_Click(object sender, EventArgs e)
{
    SqlCeConnection cn = new SqlCeConnection(@"Data Source=" + Path.Combine(Application.StartupPath, "FRAT_DB.sdf") + ";Password=P@ssw0rd;Persist Security Info=False;Max Database Size=256");

    string query = @"SELECT Person.PersonID, Person.Name, PhotoTags.PhotoID, Photo.Path, Photo.Location, Person.Age, Person.P_Group, Person.Email, Photo.Date "+
                    "FROM Person INNER JOIN PhotoTags ON Person.PersonID = PhotoTags.PersonID INNER JOIN "+
                    "PhotoON PhotoTags.PhotoID = Photo.PhotoID "+"WHERE (Person.Name LIKE '%%')";

    if (txtName1.Text.Trim().ToString() == "" || txtName2.Text.Trim().ToString() == "")
    { MessageBox.Show("Enter Both, Name1 and Name2"); return; }
    else if (radioButtonAND.Checked)
    {
        query = @"select pt.PhotoID,Photo.Path,photo.Location, Photo.Date from Person p inner join PhotoTags pt on p.PersonID=pt.PersonID inner join Photo on pt.photoID=photo.photoID where Name like '%" + txtName1.Text + "%' and pt.Photoid in (select pt.PhotoID from Person p inner join PhotoTags pt on p.PersonID=pt.PersonID where Name like '%" + txtName2.Text + "%')";
    }
    else
    {
        query = @"SELECT DISTINCT Person.PersonID, Person.Name, PhotoTags.PhotoID, Photo.Path, Photo.Location, Person.Age, Photo.Date
FROM Person INNER JOIN PhotoTags ON Person.PersonID = PhotoTags.PersonID INNER JOIN
PhotoON PhotoTags.PhotoID = Photo.PhotoID
WHERE (Person.Name LIKE '%%')";
        query += " AND (Person.Name like '%" + txtName1.Text + "%' OR Person.Name like '%" + txtName2.Text + "%')";
     }

     if (cn.State == ConnectionState.Closed) cn.Open();

     SqlCeCommand cm_Search = new SqlCeCommand(query, cn);

     try
     {
         SqlCeDataReader rdr = cm_Search.ExecuteReader();

         List<PersonPhoto> personPhoto = new List<PersonPhoto>();
         List<PersonPhotoWithoutName> personPhotoWithoutName = new List<PersonPhotoWithoutName>();

         bool HasRows = rdr.Read();

         if (HasRows)
         {
            while (rdr.Read())
            {
                if (radioButtonAND.Checked)
                {
                    personPhotoWithoutName.Add(new PersonPhotoWithoutName
                            {
                                PhotoID = Convert.ToInt32(rdr["PhotoID"].ToString()),
                                Location = rdr["location"].ToString(),
                                Date = rdr["Date"] != null ? Convert.ToDateTime(rdr["Date"]) : DateTime.Now,
                                path = rdr["path"].ToString(),
                            });
                }
                else
                {
                    personPhoto.Add(new PersonPhoto
                            {
                                Name = rdr["Name"].ToString(),
                                Location = rdr["location"].ToString(),
                                Date = rdr["Date"] != null ? Convert.ToDateTime(rdr["Date"]) : DateTime.Now,
                                path = rdr["path"].ToString()

                            });
                }
             }
             rdr.Close();
          }
          else
          { MessageBox.Show("No Records Found"); selectedPictureBox.Image = null; rdr.Close(); }

          if (personPhoto.Count > personPhotoWithoutName.Count)
          {
              DataGridPersons.DataSource = personPhoto;
              DataGridPersons.Refresh();
          }
          else
          {
              DataGridPersons.DataSource = personPhotoWithoutName;
              DataGridPersons.Refresh();
          }
      }
      catch (Exception exp)
      {
                throw exp;
      }

      if (cn.State != ConnectionState.Closed) cn.Close();
 }

Whenever I try to search for someone this exception error comes up:

There was an error parsing the query. [ Token line number = 3,Token
line offset = 18,Token in error = . ]

Any help?

thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:54:13+00:00Added an answer on June 4, 2026 at 10:54 pm

    I suspect this is the problem:

    ... INNER JOIN
    PhotoON PhotoTags.PhotoID = Photo.PhotoID ...
    

    I suspect you meant:

    ... INNER JOIN
    Photo ON PhotoTags.PhotoID = Photo.PhotoID ...
    

    Note the space between Photo and ON. I suspect you could reformat your query so this would be rather clearer, to be honest…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a program in C# using Visual Studio 2010 and gets an
I'm writing an application using Visual Studio C++ 2010 to perform Data Acquisition and
I am writing a program in C for windows using visual studio 2010. I
I am writing a bouncing logo screensaver in Visual Studio 2010 using C#. I
I am writing a program using Delphi 2006 and storing data in XML files
I am writing an application program using swing. I need to exit from the
I am wondering if I can use VB.NET(I am using visual studio 2010 express)
My scenario I'm using Visual Studio 2010 with Entity Framework 4.1 I have a
We have been getting a range on infuriating error dialogs using Visual Studio 2008
I'm on windows 7 x64. Using C++ in Visual Studio 2008 and 2010. When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.