473,888 Members | 1,346 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sharing datasources among forms - VS2005

I have come across the situation several times where a number of forms
in an app use the same datasource, for example to populate a combo
drop-down. I'm sure we've all had this. Using the IDE results in
every form getting its own Dataset, BindingSource and TableAdapter,
plus code in the Open event to fill the table in the dataset. This
strikes me as incredibly inefficient - there is simply no need for
every form to go to the database to read this data in again. What I
want is a way to set up and populate a dataset once, then just refer
to it in all the forms that might need it. Is there a way to do this
that fits in with the IDE? If there is it isn't obvious to me.

Feb 24 '07 #1
4 1220
Steve,

It is strange, because the version 2003 has this behaviour. The version 2005
creates it on its own datasource where the tableadapter can be build in. It
is a class on its own including data and connection to the database.

Can you tell us how you build up your tableadapter?

Cor

"Steve Marshall" <st****@westnet .net.auschreef in bericht
news:11******** *************@p 10g2000cwp.goog legroups.com...
>I have come across the situation several times where a number of forms
in an app use the same datasource, for example to populate a combo
drop-down. I'm sure we've all had this. Using the IDE results in
every form getting its own Dataset, BindingSource and TableAdapter,
plus code in the Open event to fill the table in the dataset. This
strikes me as incredibly inefficient - there is simply no need for
every form to go to the database to read this data in again. What I
want is a way to set up and populate a dataset once, then just refer
to it in all the forms that might need it. Is there a way to do this
that fits in with the IDE? If there is it isn't obvious to me.

Feb 24 '07 #2
If you were really concerned about the performance, you could create a
public class with shared properties that point to datatables that you're
using to bind to comboboxes all over your app, and access that everywhere.

Robin S.
-------------------------
"Steve Marshall" <st****@westnet .net.auwrote in message
news:11******** *************@p 10g2000cwp.goog legroups.com...
>I have come across the situation several times where a number of forms
in an app use the same datasource, for example to populate a combo
drop-down. I'm sure we've all had this. Using the IDE results in
every form getting its own Dataset, BindingSource and TableAdapter,
plus code in the Open event to fill the table in the dataset. This
strikes me as incredibly inefficient - there is simply no need for
every form to go to the database to read this data in again. What I
want is a way to set up and populate a dataset once, then just refer
to it in all the forms that might need it. Is there a way to do this
that fits in with the IDE? If there is it isn't obvious to me.

Feb 26 '07 #3
Yes, an approach like that has occurred to me, and I will pursue it.
It just doesn't seem to fit as naturally as I would like with the way
the IDE does things. Thanks for the reply.
On Feb 26, 9:38 am, "RobinS" <Rob...@NoSpam. yah.nonewrote:
If you were really concerned about the performance, you could create a
public class with shared properties that point to datatables that you're
using to bind to comboboxes all over your app, and access that everywhere.

Robin S.
-------------------------"Steve Marshall" <ste...@westnet .net.auwrote in message

news:11******** *************@p 10g2000cwp.goog legroups.com...
I have come across the situation several times where a number of forms
in an app use the same datasource, for example to populate a combo
drop-down. I'm sure we've all had this. Using the IDE results in
every form getting its own Dataset, BindingSource and TableAdapter,
plus code in the Open event to fill the table in the dataset. This
strikes me as incredibly inefficient - there is simply no need for
every form to go to the database to read this data in again. What I
want is a way to set up and populate a dataset once, then just refer
to it in all the forms that might need it. Is there a way to do this
that fits in with the IDE? If there is it isn't obvious to me.- Hide quoted text -

- Show quoted text -

Feb 26 '07 #4
Hi,

"Steve Marshall" <st****@westnet .net.auwrote in message
news:11******** *************@z 35g2000cwz.goog legroups.com...
Yes, an approach like that has occurred to me, and I will pursue it.
It just doesn't seem to fit as naturally as I would like with the way
the IDE does things. Thanks for the reply.
<text snipped>

Here is some addition info:

After compiling the class (example) below, you can create an object Data
Source from it (Data Source's window, add new Data Source). Once you have
the Data Source you can use it with the WinForm designer and the DataTable
will only be loaded once when it's first used.

Imports WindowsApplicat ion1.SomeDBData SetTableAdapter s

Public Class GlobalCompanyDa taSource
Implements System.Componen tModel.IListSou rce

Public Shared _Table As SomeDBDataSet.C ompanyDataTable

Public Shared ReadOnly Property Table() As
SomeDBDataSet.C ompanyDataTable
Get
If (_Table Is Nothing) Then
_Table = New SomeDBDataSet.C ompanyDataTable
Dim cta As New CompanyTableAda pter
cta.Fill(_Table )
cta.Dispose()
End If
Return _Table
End Get
End Property

Public ReadOnly Property ContainsListCol lection() As Boolean Implements
System.Componen tModel.IListSou rce.ContainsLis tCollection
Get
Return False
End Get
End Property

Public Function GetList() As System.Collecti ons.IList Implements
System.Componen tModel.IListSou rce.GetList
Return Table.DefaultVi ew
End Function
End Class

If your form needs to contain global and a non global DataTable's which are
part of the same DataSet, then you could just use the DataSet on the Form
and then replace the fill line in Form_Load for the global DataTable, this
way you can still enforce referential integrity (fk constraints).

Private Sub Form_Load(...)
' fill lookup (global)
SomeDBDataSet.C ompany.Merge(Co mpanyGlobalSour ce.Table)

' fill master (non-global)
EmployeeTableAd apter.Fill(Some DBDataSet.Emplo yee)
End Sub
HTH,
Greetings
Feb 26 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2855
by: Robert W. | last post by:
I'm embarking on a project that will have both a desktop application and a Pocket PC application. It seems logical to have as much code as possible sitting in a shared project, which would be referenced and utilized by both the Windows Forms application and the Mobile Device application. Are there any "gotchas" (ie. warnings) that anyone knows about in following this approach? Robert W. Vancouver, BC
4
2343
by: qube3 | last post by:
We have applications written by JSP/Servlet and ASP.NET. All our future development would be based on ASP.NET. We wants to develop a single user interface so that users would not be aware that some of the modules they are using are implement by JSP or ASP.NET (e.g. no need to login both JSP and ASP.NET applications)? Are there any suggestions to share the session in formation among JSP and ASP.NET, or some single-sign on solution.
2
1207
by: brucedodds2 | last post by:
I have a client with an Access 97 format switchboard based application. This app is shared across several offices which are being upgraded in sequence to Access XP. Recently XP users started having the startup switchboard halt before any items are displayed. Access 97 users still get the correct startup. Are there known issues in sharing A97 format applications among XP and 97 users? (This app has tables & forms in one file). TIA
0
1218
by: Tina | last post by:
I'm reading articles on the new TableAdapters where it says that a key new advantage is that a single TableAdapter, which can have multiple queries, can be used on multiple forms. Now that was in an article on using TableAdapters with Forms Apps. There is a DataSource window that stores common datasources for the whole project (accessed via the Data menu item). Now, back to ASP apps - there is no Data on the menu, no datasource window,...
9
2923
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got answered... There are articles on the new TableAdapters where it says that a key new advantage is that a single TableAdapter, which can have multiple queries, can be used on multiple forms. Now that was in an article on using TableAdapters with...
2
1725
by: Carlo \(MCP only\) | last post by:
Hi to all I'm askyng you a suggestion about the best way to share the same source code between VS2003 and VS2005. The project I'm developing is a controls and components library, and the Solution.sln includes a standard WindowsForms application for testing pourposes. What I need is an efficient and reliable way to edit and test the DLL assembly in both environments, since the library will be distributed for Framework 1.1 and 2.0.
1
1736
by: Leon_Amirreza | last post by:
Hi, I am wondering if there is a way to share a Dataset object on the main form of my C# App between other forms that I can bind other forms controls to this dataset (designer is not aware of a public member of the mdi parent form)? Or any better practice than sharing a dataset among forms? I need a centeral managable access to the database! thanks
19
3171
by: cpnet | last post by:
I'm using VS2005, C#, ASP.NET 2.0. I'm trying to create a report using SQL Reporting Services (to be used in local mode so I don't have to deal with SQL Server). When I create a new report in my website, nothing shows up in the Website Data Sources window. I added a few different strongly-typed Datasets to my website, and they don't show up. The only way I could get anything to show up was to create a new class that's derived from a...
0
1579
by: grmiked | last post by:
Hallo everybody, I am working with VS2005 and have a major problem with VC++ and Crystal Reports that has been driving me crazy for the last 1 week! More specifically, my problem situation can be perfectly described with the following simplified scenario: I create a new VC++ project of type "Windows Forms Application" and add a new DataSet that I connect to a dummy Access database that just contains one table. Then, I add a new...
0
9961
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10780
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9597
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7991
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5825
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6015
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4248
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3252
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.