1

Am having some SQL (SqlCe) issues I was getting the following error:

There was an error parsing the query.

(1) ERROR:> [Token Line number = 1, Token Line offset 853, Token in error = @clID]

from the following SQL line:

mySQLCommand1.CommandText = "INSERT into clientSubjectiveComplaints (clientSubComplaintCreated,clientSubComplaintModified,clientSubComplaintAge,clientSubComplaintWeight,clientSubComplaintHeight,clientSubComplaintConfirmation,clientSubComplaintEnviorment,clientSubComplaintFood,clientSubComplaintPresentComplaint,clientSubComplaintHistoryofPresentComplaint,clientSubComplaintPastMedicalHistory,clientSubComplaintMedication,clientSubComplaintLastDentalCheckUp,clientID) VALUES (@ClientSubComplaintCreated, @ClientSubComplaintModified, @ClientSubComplaintAge, @ClientSubComplaintWeight, @ClientSubComplaintHeight, @ClientSubComplaintConfirmation, @ClientSubComplaintEnviorment, @ClientSubComplaintFood,@ClientSubComplaintPresentComplaint, @ClientSubComplaintHistoryofPresentComplaint, @ClientSubComplaintPastMedicalHistory, @ClientSubComplaintMedication, @ClientSubComplaintLastDentalCheckUp, @clID";

This was when I was trying to insert into the table clientSubjectiveComplaint.

enter image description here NOTE: The above db Validates ok.

Assuming after reading around the internet a bit that it might be a Private Key Foreign Key issue but I am not entirely sure.

I changed some of the table to 1:1 relationships (see image below) as it makes more sense anyways but then stated reading that if you have a 1:1 relationship then it expects the Primary Key to be the same for the tables. See Here

So to the QUESTION:

What was meant by the original error (1) and why was i getting the Token error?

And Secondly:

Assuming the PK key issue in the See Here is correct then what is the correct procedure for making 1:1 relationships.

Thanks.

enter image description here

Community
  • 1
  • 1
DevilCode
  • 1,054
  • 3
  • 35
  • 61

1 Answers1

2

You are missing the closing parenthesis from your query in mySQLCommand1.CommandText

In other words, it should be:

mySQLCommand1.CommandText = "INSERT into clientSubjectiveComplaints (clientSubComplaintCreated,clientSubComplaintModified,clientSubComplaintAge,clientSubComplaintWeight,clientSubComplaintHeight,clientSubComplaintConfirmation,clientSubComplaintEnviorment,clientSubComplaintFood,clientSubComplaintPresentComplaint,clientSubComplaintHistoryofPresentComplaint,clientSubComplaintPastMedicalHistory,clientSubComplaintMedication,clientSubComplaintLastDentalCheckUp,clientID) VALUES (@ClientSubComplaintCreated, @ClientSubComplaintModified, @ClientSubComplaintAge, @ClientSubComplaintWeight, @ClientSubComplaintHeight, @ClientSubComplaintConfirmation, @ClientSubComplaintEnviorment, @ClientSubComplaintFood,@ClientSubComplaintPresentComplaint, @ClientSubComplaintHistoryofPresentComplaint, @ClientSubComplaintPastMedicalHistory, @ClientSubComplaintMedication, @ClientSubComplaintLastDentalCheckUp, @clID)";

Meaning it should end like this: , @clID)";

Tom Chantler
  • 14,753
  • 4
  • 48
  • 53
  • If you knew how many times I've done something similar you'd laugh! The best way to solve problems like this is to explain them to somebody (either in person, or online). Sometimes the act of explaining helps you to see the problem, other times the person you are explaining to can see it. Overall it saves a lot of time. It's also good for the soul to admit that one is not always perfect! I think it's a good habit so I have upvoted the question! – Tom Chantler Jun 28 '11 at 22:09