数据适配器错误 [英] dataadapter error

查看:116
本文介绍了数据适配器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在开发一个Windows应用程序,该应用程序使用查询来填充水晶报表.
我收到以下错误:无法启用约束.一个或多个行包含违反非null唯一或外键约束的值"

这是代码

SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd, DBConnection.GetSqlConnction());
DataSet ds = new DataSet();
dataAdapter.Fill(ds, "Machines");



我在最后一行收到此异常.

注意:当我使用与其他表没有任何关系的表时,该代码有效.

谢谢您

解决方案

请参阅

您是否正确指定了选择查询.

只需尝试

SELECT * FROM TABLE,我认为它将起作用.

如果您不在数据集中创建关系,则不会造成任何问题.:rose:


好..您的代码清单并未真正显示出太多的错误..但我建议您尝试这种方法..

1.创建用于创建数据集的原始查询的存储过程.

2.现在,在Crystal Reports设计视图中,使用数据库"选项卡,将数据源引用到数据库的存储过程,并根据存储的proc的参数合并数据域.

..

现在剩下的只是简单的水晶报表设计了.
我相信它应该可以工作:)初学者,我不知道如何编写存储过程.

所以请大家帮我解决这个错误


Hi,

I''m developing a windows application that uses query to fill crystal reports.
I''m getting the following error: "Failed to enable constraints. One or more rows contain values violating non null unique or foreign-key constraints"

Here is the code

SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd, DBConnection.GetSqlConnction());
DataSet ds = new DataSet();
dataAdapter.Fill(ds, "Machines");



I''m getting this exception in the last line.

note: The code works when I use a table that does not have any relations with other tables.

Thank you

解决方案

See,

Did you specified the Select Query properly.

Just try

SELECT * FROM TABLE, it will work I think.

If you dont create relationship in the dataset, it will not create any problem.:rose:


ok..your code listing doesnt really show much about the error..but I would suggest you try this approach..

1.create a stored procedure of the original query you''re using to make your dataset.

2. Now in the crystal reports design view, using the database tab, refer your datasource to the stored procedure of the database and pool your data feilds from the parameters of the stored proc.

..

Now the rest is just simple crystal report designs..blah blah..

And it should be working, I believe :)


thank u for fast answers but iam sure that the query is written correct also there are no relations in the dataset, and also i''m beginner i dont know how to write stored procedures.

so plz could anyone help me to solve this error


这篇关于数据适配器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆