473,587 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Link form DataSet to business layer DataSet, whilst maintaining design-time databinding support

I have a DataSet that bound to controls on multiple forms. Currently
an instance is created on each form and Load / Write is handled on
each form.

Instead I would like to have a single instance DataSet that is
accessed and maintained by Data Access Object (DAO) and I would like
that DataSet to be re-used on each form.

The problem I have is that when I drag a DataSet component onto a
form, I am having trouble linking it to the DataSet in the DAO class.

Dao class:

public class MantraXDao
{
private MantraXDao( )
{
m_dataSet = new MantraDataSet( );
m_dataSet.DataS etName = "MantraDataSet" ;
m_dataSet.Local e = new
System.Globaliz ation.CultureIn fo("en-AU");

Load( );
}

#region public interface

public void Load( )
{
m_dataSet.Clear ( );
m_dataSet.ReadX ml( "MantraX.xm l" );
}

public void Write( )
{
m_dataSet.Write Xml( "MantraX.xm l" );
}

#endregion

#region properties

public static MantraXDao Instance
{
get
{
if ( m_instance == null )
{
m_instance = new MantraXDao( );
}
return m_instance;
}
}

public MantraDataSet DataSet
{
get
{
return m_dataSet;
}
}

#endregion

#region fields

private static MantraXDao m_instance;

private MantraDataSet m_dataSet;

#endregion

}
// Calling conventions from each form
MantraXDao.Inst ance.Read // Refresh DataSet
MantraXDao.Inst ance.Write // Write DataSet
MantraXDao.Inst ance.DataSet // Obtain DataSet Instance

Cheers Dave
Nov 15 '05 #1
2 1731
Use Public Shared vaiable or Singleton method to access the same dataset to all form

Regard
Amal
Nov 15 '05 #2
D C
A singleton is essentially what I have done with this class already.
I've used a Factory pattern that only allows one instance of the DAO,
which wraps the DataSet.

The question is that I would like to drag that (SingleInstance ) DataSet
into any form at designtype so that the DataBound properties on each
control can access the DataSet.

When you drag a DataSet onto a form, a wizard comes up that allows you
to select a previously created DataSet as a reference, but that wizard
won't allow me to get that reference from my DAO class.

Currently I have had to manually create the DataBinding:

private void InitDataSet( )
{
mantraDataSet = MantraXDao.Inst ance.DataSet;

dgMantra.DataSo urce = mantraDataSet;
dgMantra.DataMe mber = "Mt_Category.Mt _CategoryMt_Man tra";

dgCategory.Data Source = mantraDataSet;
dgCategory.Data Member = "Mt_Categor y";

cmbSkinType.Dat aBindings.Add(n ew Binding("Select edItem",
mantraDataSet, "Mt_Config.Skin Type"));
cmbSkinType.Dat aBindings.Add(n ew Binding("Select edValue",
mantraDataSet, "Mt_Config.Skin Type"));
cmbSkinType.Dat aBindings.Add(n ew Binding("Text", mantraDataSet,
"Mt_Config.Skin Type"));

cmbAutoDisplay. DataBindings.Ad d(new Binding("Select edItem",
mantraDataSet, "Mt_Config.Auto Display"));
cmbAutoDisplay. DataBindings.Ad d(new Binding("Select edValue",
mantraDataSet, "Mt_Config.Auto Display"));
cmbAutoDisplay. DataBindings.Ad d(new Binding("Text",
mantraDataSet, "Mt_Config.Auto Display"));
}

Cheers Dave


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #3

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

Similar topics

6
5743
by: Hamed | last post by:
Hello I have employed as a developer in a software company that its team uses FoxPro / VB 6.0 / VC++ 6.0 as the developing tools and newly is going to migrate to VS.NET. There is a project modified that is to upgrade a big, more than 100,000 lines DOS based program developed by FoxPro 2.x to .NET platform. The design is as previous and...
4
6813
by: geilen | last post by:
I'm trying to use a dataset returned from a web service in an unmanaged C++ (MFC) client. The dataset is returned as a BSTR, and I'm having trouble reading the BSTR into an XML document for processing. The data looks correct in the BSTR. Can anyone help point me in the right direction on this?
12
378
by: Hamed | last post by:
Hello I have employed as a developer in a software company that its team uses FoxPro / VB 6.0 / VC++ 6.0 as the developing tools and newly is going to migrate to VS.NET. There is a project modified that is to upgrade a big, more than 100,000 lines DOS based program developed by FoxPro 2.x to .NET platform. The design is as previous and...
8
1752
by: Charles Law | last post by:
This is a sort of pattern question, but relating to how components are coupled in a three-tier system. I have a presentation layer, business layer and data access layer, the first is the EXE, whilst the other two are implemented as DLLs. The EXE also references a DLL that contains various user controls, one of which is based on a grid...
8
1416
by: Charles Law | last post by:
This is a sort of pattern question, but relating to how components are coupled in a three-tier system. I have a presentation layer, business layer and data access layer, the first is the EXE, whilst the other two are implemented as DLLs. The EXE also references a DLL that contains various user controls, one of which is based on a grid...
0
7918
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...
0
8206
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8340
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...
1
7967
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...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3840
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...
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1185
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...

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.