I have the following query called searchit

```
SELECT 2 AS sourceID, BLOG_COMMENTS.bID, BLOG_TOPICS.Topic_Title,
    BLOG_TOPICS.LFD, BLOG_TOPICS.LC,
    BLOG_COMMENTS.Comment_Narrative
FROM BLOG_COMMENTS INNER JOIN BLOG_TOPICS
    ON BLOG_COMMENTS.bID = BLOG_TOPICS.bID
WHERE  (BLOG_COMMENTS.Comment_Narrative LIKE @Phrase)

```

This query executes AND returns the correct results in the query builder!
HOWEVER, the query needs to run in code-behind, so I have the following line:

```
DataTable blogcomments = btad.searchit(aphrase);

```

There are no null fields in any row of any column in EITHER of the tables. The tables are small enough I can easily detect null data. Note that bID is key for blog\_topics and cID is key for blog comments.

In any case, when I run this I get the following error:

> 
> Failed to enable constraints. One or more rows contain values
>  violating non-null, unique, or foreign-key constraints.
> 
> 
> 

Tables have a 1 x N relationship, many comments for each blog entry. IF I run the query with DISTINCT and remove the Comment\_Narrative from the return fields, it returns data correctly (but I need the other rows!) However, when I return the other rows, I get the above error!

I think tells me that there is a constraint on the return table that I did not put there, therefore it must somehow be inheriting that constraint from the call to the query itself because one of the tables happens to have a primary key defined (which it MUST have). But why does the query work fine in the querybuilder? The querybuilder does not care that bID is duped in the result (and it should not be), but the code-behind DOES care.

Addendum:

Just as tests,

1. I removed the bID from the return list and I still get the error.
2. I removed the primary key from blog\_topics.bID and I get the same error.

This kinda tells me that it's not the fact that my bID is duped that is causing the problem.

Another test:
I went into the designer code (I know it's nasty, I'm just desperate).
I added the following:

```
    // zzz
    try
    {

        this.Adapter.Fill(dataTable);
    }
    catch ( global::System.Exception ex )
    {

    }

```

Oddly enough, when I run it, I get the same error as before AND it doesn't show the changes I've made in the error message:

```
Line 13909:            }
Line 13910:            BPLL_Dataset.BLOG_TOPICSDataTable dataTable = new BPLL_Dataset.BLOG_TOPICSDataTable();
Line 13911:            this.Adapter.Fill(dataTable);
Line 13912:            return dataTable;
Line 13913:        }

```

I'm stumped.... Unless maybe it sees I'm not doing anything in the try catch and is optimizing for me.

Another addendum:
Suspecting that it was ignoring the test code I added to the designer, I added something to the catch. It produces the SAME error and acts like it does not see this code. (Well, okay, it DOES NOT see this code, because it prints out same as before into the browser.)

```
    // zzz
    try
    {

        this.Adapter.Fill(dataTable);
    }
    catch ( global::System.Exception ex )
    {
        System.Web.HttpContext.Current.Response.Redirect("errorpage.aspx");
    }

```

The thing is, when I made the original post, I was ALREADY trying to do a work-around. I'm not sure how far I can afford to go down the rabbit hole. Maybe I read the whole mess into C# and do all the joins and crap myself. I *really* hate to do that, because I've only recently gotten out of the habit, but I perceive I'm making a good faith effort to use the the tool the way God and Microsoft intended. From wit's end, tff.