473,383 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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.DataSetName = "MantraDataSet";
m_dataSet.Locale = new
System.Globalization.CultureInfo("en-AU");

Load( );
}

#region public interface

public void Load( )
{
m_dataSet.Clear( );
m_dataSet.ReadXml( "MantraX.xml" );
}

public void Write( )
{
m_dataSet.WriteXml( "MantraX.xml" );
}

#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.Instance.Read // Refresh DataSet
MantraXDao.Instance.Write // Write DataSet
MantraXDao.Instance.DataSet // Obtain DataSet Instance

Cheers Dave
Nov 15 '05 #1
2 1723
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.Instance.DataSet;

dgMantra.DataSource = mantraDataSet;
dgMantra.DataMember = "Mt_Category.Mt_CategoryMt_Mantra";

dgCategory.DataSource = mantraDataSet;
dgCategory.DataMember = "Mt_Category";

cmbSkinType.DataBindings.Add(new Binding("SelectedItem",
mantraDataSet, "Mt_Config.SkinType"));
cmbSkinType.DataBindings.Add(new Binding("SelectedValue",
mantraDataSet, "Mt_Config.SkinType"));
cmbSkinType.DataBindings.Add(new Binding("Text", mantraDataSet,
"Mt_Config.SkinType"));

cmbAutoDisplay.DataBindings.Add(new Binding("SelectedItem",
mantraDataSet, "Mt_Config.AutoDisplay"));
cmbAutoDisplay.DataBindings.Add(new Binding("SelectedValue",
mantraDataSet, "Mt_Config.AutoDisplay"));
cmbAutoDisplay.DataBindings.Add(new Binding("Text",
mantraDataSet, "Mt_Config.AutoDisplay"));
}

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
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...
4
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...
12
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...
8
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,...
8
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,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.