简体   繁体   English

VB.net在应用程序启动时填充数据集

[英]VB.net Fill Dataset at Application Start

I have a winforms application that has an sql server backend. 我有一个具有SQL Server后端的Winforms应用程序。 I have some tables that have static data, lookup tables, that I would like to fill in my dataset at application start to be used throughout the application when needed. 我有一些具有静态数据的表,即查询表,我希望在应用程序开始时填写我的数据集,以便在需要时在整个应用程序中使用。

Normally in a form I would use something like this: Me.TEMSWBSETableAdapter.Fill(Me.EMS_DS.TEMSWBSE) 通常,在某种形式下,我将使用以下形式:Me.TEMSWBSETableAdapter.Fill(Me.EMS_DS.TEMSWBSE)

But I would have to do that in every form that required that data. 但是我必须以需要该数据的每种形式来执行此操作。 The problem is it takes awhile to load that data, so I would like to load the data at startup in a background worker that can be used by any form that requires it. 问题是加载该数据需要花费一些时间,因此我想在启动时在后台工作程序中加载数据,该工作程序可由需要它的任何形式使用。 Basically filling the dataset with that data for use throughout. 基本上用该数据填充数据集以供整个使用。

I am not sure how to do this. 我不确定该怎么做。 Can someone point me in the right direction. 有人可以指出我正确的方向。 Thanks 谢谢

you first need to implement DataReder object that can retrieve data with out creating a database TableAdapter. 您首先需要实现DataReder对象,该对象可以在不创建数据库TableAdapter的情况下检索数据。 this will load your data with forward only and read only mode of the ADO.net mechanism.then you can implement ExecuteNonQuery() method to append the changes directly to the database. 这将使用ADO.net机制的正向和只读模式加载数据。然后,您可以实现ExecuteNonQuery()方法以将更改直接附加到数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM