FillSchema, Constraints and Stored Procedures

G

Guest

I'm filling DataTables from a SQL2005 database using either simple "select
.... from ..." or stored procedures as the data source. Before I get the data
itself I call FillSchema because there are a couple of things I want to do
depending on some column properties. This all works just fine.

Now, with one particular stored procedure, Fill fails due to a violation of
non-null or unique constraints. I've checked all the columns in the data
table after FillSchema and indeed, one of them is declared as unique - but
the data returned by the query isn't. So the violation error is actually
correct.

But I don't want this column to be considered unique, it contains a foreign
key, and I can't understand why FillSchema thinks it is. I have another
almost identical stored proc, which also returns the column in question - and
which does not cause the error. Where's the difference? If there is one, I
haven't found it yet!

I don't want to manually correct the unique property for this column in my
FillSchema code; that would be too specific and doesn't make sense. There
must be some reason for it.

If necessary, I'll post code, but the sps are rather involved. Perhaps
someone has an idea just from the problem description. Any tips on how
FillSchema decides if a column is unique or not would be appreciated as well.

Thanks
Tom
 
G

Guest

A short update: FillSchema thinks the column is the basis for the primary key
for the table returned by my query, which is absolute nonsense, of course.
Now how do I let FillSchema know that some other column is the primary key
for my stored procedure...?
 
W

WenYuan Wang

Hi Tom,

As far as I know, "FillSchemal" method determines whether or not a column
is unique or not by primary key and unique constraint.
I have performed research on this issue but I'm afraid it is very difficult
to figure out the root cause immediately without actual data and scenario
information.

Would you please paste your code and stored procedure in Newsgroup if it is
possible and we can perform further analysis? Please feel free to reply if
you have any concern on it. I'm glad to assist you.

Have a great weekend,
Best regards,
Wen Yuan
 
W

WenYuan Wang

Hi Tom,

I haven't heard from you two days. I just want to check if the issue has
been resolved?
If it still persists, would you mind posting some code in newsgroup?
We'll go on to assist you on it. Thanks.

Best regards,
Wen Yuan
 
G

Guest

Hello Wen Yuan,

sorry I didn't answer sooner; I've been on vacation. During the past week
requirements have changed a bit, meaning I don't need a solution to the
problem I was working on before, at least not at the moment.

The root cause of this issue still intrigues me, but for now I can't invest
any more time into investigating it. If I'm ever in the same situation again,
I'll be sure to post again here and ask for help.

Thank you
Tom
 
W

WenYuan Wang

Sure, Tom.:)
You are welcome. I'm very glad to assist you.

Have a great day.
Wen Yuan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top