将数据集表适配器添加到ApplicationEvents.vb?
我的 ApplicationEvent.vb 中有一些代码来处理命令行参数,然后根据在 cmd 中输入的任何参数运行一些程序。
问题是我需要执行一个包含数据集表适配器的过程。
显然,因为我希望它以批处理模式运行,所以我不能拥有表适配器,因为它们是基于 GUI 的(或者至少我认为它们是),所以我收到此错误:
'V_SyncStatusTableAdapter' 不是以下成员'AppName.My.MyApplication'
对于此代码:
If Me.V_SyncStatusTableAdapter.GetData.Rows.Count > 0 Then
drSyncResult = Me.V_SyncStatusTableAdapter.GetData.Rows(0)
现在这显然是因为表适配器还没有,并且 AFAIK 无法放入 ApplicationEvents.vb 文件中。
我知道数据集名为:dsetWorkingTables
,表名为v_SyncStatus
。我已经尝试过:
dsetWorkingTablesTableAdapters.v_SyncStatusTableAdapter.GetData
,但这给出了:
对非共享成员的引用需要对象引用
所以我的问题是:
如何从ApplicationEvents.vb 文件中的数据集?
I have some code in my ApplicationEvent.vb to handle command line params and then run some procedures based on whatever param was input at cmd.
The problem is that I need to execute a procedure that has a dataset table adapter in it.
Obviously as I want it to run in batch mode I can't have a table adapter as they are GUI based (or at least I think they are) so I am getting this error:
'V_SyncStatusTableAdapter' is not a member of 'AppName.My.MyApplication'
For this code:
If Me.V_SyncStatusTableAdapter.GetData.Rows.Count > 0 Then
drSyncResult = Me.V_SyncStatusTableAdapter.GetData.Rows(0)
Now this is obviously because the table adapter hasn't and AFAIK can't be put into the ApplicationEvents.vb file.
I know that the dataset is called: dsetWorkingTables
and the table is called v_SyncStatus
. I have tried:
dsetWorkingTablesTableAdapters.v_SyncStatusTableAdapter.GetData
but that gives:
reference to non shared member requires object reference
So my question is:
How do I get data from a dataset in the ApplicationEvents.vb file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要根据表适配器所在的表单类来引用表适配器。即使使用表单,您仍然可以随意访问表单上的方法,您要避免的是 form.Show() ,它会导致表单出现在屏幕。
You need to referene your table adapter against the form class it exists in. Even with forms, you can still access methods on the forms as you will, what you want to avoid is form.Show() which will case the form to appear on screen.
您的表适配器是否位于与应用程序事件不同的项目中?如果是这样,您需要引用该项目。
表适配器不仅适用于 GUI,还可以在批处理或控制台应用程序中使用。
Is your table adapter in a separate project from your Application Events? If so, you need to reference that project.
Table Adapters are not just for GUI, they can be used in batch or console apps as well.