为什么我的 DataAdapter “填满”只有第二次吗? SQL Server 紧凑型
一些背景: 我正在尝试使用 ADO.NET 同步服务(特别是 LocalCache 自定义工具)为我的应用程序创建服务器/客户端同步方案,该工具为我设置了整个过程。 我的服务器数据库有 5 个表,所有这些表都同步到客户端应用程序,客户端应用程序现在有一个 SQL Server Compact DB,其架构与服务器数据库相同。我有一个包含一些自定义查询的数据集,用于将我的应用程序与本地数据库连接。 到目前为止,一切都很好。 然而,在我的应用程序中,当我尝试使用表单上的表适配器填充其中一个表(默认的“填充”方法)时,它会出现以下异常:
不存在从 DbType 对象到已知 SqlDbType 的映射。
但是,如果我继续并再次填充,它就可以正常工作。
Try
Me.WTSUsersTableAdapter.Fill(Me.WTSMainDataSet.WTSUsers)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
如果我将上述代码执行两次,一次紧接着另一次,则第一个失败,第二个有效。
另一点需要提及的是,这种情况仅发生在该数据表上,数据库中的所有其他 4 个表都按预期工作。
有谁知道这可能是什么原因?
非常感谢
编辑:我删除了我的数据集并重新创建它但没有成功。有人对我有想法吗?
Some background:
I'm trying to create a Server/Client Sync scenario for my application using Sync Services for ADO.NET specifically the LocalCache custom tool which sets the whole thing up for me.
My server DB has 5 Tables, all of which are being synchronized to the client application, which now has a SQL Server Compact DB with the same schema as the server DB. I have a dataset with some custom queries that I use to connect my app with the local database.
So far so good.
However in my application when I try to fill one of my tables with the table adapter on my form (the default "fill" method) it gives me the following exception:
No mapping exists from DbType Object to a known SqlDbType.
However, if I continue and do the fill again, IT WORKS without a problem.
Try
Me.WTSUsersTableAdapter.Fill(Me.WTSMainDataSet.WTSUsers)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
If I do the above code twice, one right after the other, the first one fails, the second works.
Another point to mention is that this happens only with this datatable, all the other 4 tables in the DB work as expected.
Does anyone have an idea what could be the cause of this?
Thanks a lot
Edit: I deleted my dataset and recreated it with no success. Anyone have an idea for me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了我的问题的答案。我为表适配器输入的自定义“UPDATE”查询存在问题。由于某种原因,这阻止了表适配器执行简单的“填充”,但仅限于第一次尝试。它似乎并不关心我第二次尝试时的更新错误...
看图。
为了发现问题,我所做的就是从适配器中删除每个自定义查询,然后一次添加一个查询,以查看导致错误的原因。
I found the answer to my question. There was a problem with a custom "UPDATE" query I had entered for the table adapter. For some reason, this prevented the table adapter from performing a simple "Fill", but only on the first try. It didn't seem to care about my Update error on the second try...
Go Figure.
What I did to find the problem was delete each custom query from the adapter and add them one at a time to see what was causing the error.