2008-01-30, 11:26 AM
Very occasionally the following SQL query code throws an Exception.Message "Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints."
It doesn't happen often, but I cannot find out why it occurs when it does.
Does anyone have some ideas on what is going on and how to prevent the errors from occurring?
Code:
public bool LiveTV(int Channel_Number)
{....
DateTime now = DateTime.Now;
_strSQL = "SELECT programme.oid, channel.name, programme.name, description, start_time, end_time ";
_strSQL += "FROM programme, channel ";
_strSQL += "WHERE channel.oid=programme.channel_oid ";
_strSQL += "AND channel.channel_number= " +Channel_Number;
_strSQL += " AND start_time <='" + now.ToString("yyyy-MM-dd HH:mm") +"'" ;
_strSQL += " AND end_time >='" + now.ToString("yyyy-MM-dd HH:mm") +"' ;";
DbCommand command = connection.CreateCommand();
DataTable dt = new DataTable();
command.CommandText=_strSQL;
dt.Load(command.ExecuteReader());
.....
}
It doesn't happen often, but I cannot find out why it occurs when it does.
Does anyone have some ideas on what is going on and how to prevent the errors from occurring?
[SIZE="1"]Silverstone GD01S-MXR (three dead rows of pixels in the LCD and defective remote control), Power: Zalman ZM460B-APS (blew up - can't remember what's there now); CPU: Pentium D 3.2 GHz with Asus V72 Cooler; MD: Asus P5LD2 Deluxe 2048MB,
WDC WD10EADS 1TB Data, 320GB System, Asus EN9400GT Silent 512MB, Hauppauge HVR 1300,
XP Home SP3, GB-PVR 2.0, ExternalDisplay v0.3[/SIZE]
WDC WD10EADS 1TB Data, 320GB System, Asus EN9400GT Silent 512MB, Hauppauge HVR 1300,
XP Home SP3, GB-PVR 2.0, ExternalDisplay v0.3[/SIZE]