我得到一個未處理的異常約束,當我運行一組特定的PARAMATERS的下面的代碼:ConstraintException但我不知道爲什麼!
using (MySqlConnection connMySql = new MySqlConnection(global.g_connString))
{
MySqlCommand cmd = connMySql.CreateCommand();
cmd.CommandText = this.Query;
connMySql.Open();
using (MySqlDataReader dr = cmd.ExecuteReader())
{
DataTable dt = new DataTable();
dt.Load(dr);
return dt;
}
但是,如果我運行查詢直接的(即不是我的應用程序,但使用查詢瀏覽器)我看不到任何空值或任何會產生錯誤的內容。
它必須是數據特定的,就像我改變我的查詢的日期範圍它工作正常。
任何人有任何想法?
感謝,
本
PS查詢如下:
SELECT COALESCE(ti.FIRST_NAME, 'Not Assigned') AS 'Technician',wo.WORKORDERID 'Request ID',aau.FIRST_NAME 'Requester', wo.TITLE 'Subject', rrs.resolution As Resolution, (wo.COMPLETEDTIME/1000) 'TimeStamp'
FROM WorkOrder_Threaded wot
INNER JOIN WorkOrder wo ON wot.WORKORDERID=wo.WORKORDERID
LEFT JOIN SDUser sdu ON wo.REQUESTERID=sdu.USERID
LEFT JOIN AaaUser aau ON sdu.USERID=aau.USER_ID
LEFT JOIN WorkOrderStates wos ON wo.WORKORDERID=wos.WORKORDERID
LEFT JOIN SDUser td ON wos.OWNERID=td.USERID
LEFT JOIN AaaUser ti ON td.USERID=ti.USER_ID
LEFT JOIN RequestResolution rrs ON wo.WORKORDERID=rrs.REQUESTID
WHERE (wo.COMPLETEDTIME != 0) AND (wo.COMPLETEDTIME != -1) AND (wo.COMPLETEDTIME IS NOT NULL)
AND wo.COMPLETEDTIME >= (UNIX_TIMESTAMP(TIMESTAMP('" + sdChartRange.From + @"')) * 1000)
AND wo.COMPLETEDTIME <= (UNIX_TIMESTAMP(TIMESTAMP('" + sdChartRange.To + @"')) * 1000)
AND wot.THD_WOID=wot.WORKORDERID
ORDER BY Technician ASC
凡sdChartRange.From和。要爲datetime值。
請告訴我們的數據庫和查詢本身的結構..你擁有對數據庫的任何約束。因爲只有在違反某些約束條件時纔會引發此錯誤。 – 2011-01-25 12:31:50