外键,私钥MSSQL 1:1和1:很多问题

时间:2011-06-28 21:46:26

标签: c# mysql sql sql-server-ce

我遇到了一些SQL( SqlCe )问题我收到了以下错误:

解析查询时出错。

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

来自以下SQL行:

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";

这是我试图插入表格 clientSubjectiveComplaint 的时候。

enter image description here 注意:上面的db验证确定。

假设在互联网上阅读之后可能会出现私钥外键问题,但我并不完全确定。

我将一些表改为1:1关系(见下图),因为它更有意义,但随后说明如果你有一个1:1的关系,那么它希望主键是相同的表。 See Here

所以问题

原始错误(1)是什么意思,为什么我收到令牌错误?

其次:

假设See Here中的PK密钥问题是正确的,那么建立1:1关系的正确程序是什么。

感谢。

enter image description here

1 个答案:

答案 0 :(得分:2)

您在mySQLCommand1.CommandText

中缺少查询的右括号

换句话说,它应该是:

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)";

意思是它应该像这样结束:, @clID)";