开发者

Dataset constraints from DB .net 3.5

i have a stored procedure in the DB that returns different columns for different conditions. (dynamic SQL). but when i use the sqlhelper class and execute the stored proc in my business layer, it returns all the possible columns (from all if/else conditions in the dynamic sql) in the dataset returned. the other columns that should not be a part of the result set are just blank. but those columns come back with the DB constraints on them. every time i use the dataset i have to set "enforceconstraints" to false. is there a better approach, 1) to avoid bringing the constraints back 开发者_如何转开发from the DB? or 2) to get only those required dynamic columns from the DB?

thank you


Are your datatables being generates weakly or are you using strongly typed datasets?

Probably not what you want to hear, but my advice would be to have different SPs for the different result sets. All of the inference of result sets for e.g. datasets works off the SP but if the SP can return different things based on the supplied data, you'll start to see issues like you've seen.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜