473,756 Members | 5,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing DataSet between forms

1 New Member
Hi,

I searched this forum but not found a answer to fit my needs. The problem is: I have 2 forms and one dataset on the parent form who fill a DataGridView. I've passed the dataset to the child form (through a constructor), but now I need the data to be sent back to parent form. The DataSet on the child had some rows removed or added.

Expand|Select|Wrap|Line Numbers
  1. DataSet _dSet;
  2. //..........
  3. public Child(DataSet dSet)
  4.         {
  5.             InitializeComponent();
  6.             _dSet = dSet.Copy();
  7.         }
  8.  
If i put _dSet = dSet; then my DataSet on the parent is modifying when I delete or add a row (in real time). So when I want to close the child form whitout any modification, the DataSet on parent doesn't change back to the original one.

And on the parent

Expand|Select|Wrap|Line Numbers
  1. DataSet dSet;
  2. //..............
  3. private void childButton_Click(object sender, EventArgs e)
  4.         {
  5.             Child child= new Child(dSet);
  6.             //.......
  7.         }
  8.  
So the final question is how do I make the Dataset on the parent to not change IF i close the child form (from X) and on the other hant to change (with the new one) IF I press OK Button.

Thank you.
Jul 14 '10 #1
2 3805
shaahin
11 New Member
Hi
Define a dataset property in ur form.
and get it from another form
like a valuable.
modifier should be public.
good luck
Jul 19 '10 #2
GaryTexmo
1,501 Recognized Expert Top Contributor
I disagree, Shaahin. You shouldn't just make a member variable public to expose access.

One option is to write a property for it. This allows you to control access. For something like a data set, you typically want get access only. This still lets you change the contents of the dataset, but it doesn't allow the destruction of the dataset from an external source (ie, another class).

Here's an MSDN page on properties...
http://msdn.microsoft.com/en-us/libr...8VS.80%29.aspx
Jul 19 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
4314
by: Andy | last post by:
Hello, I have a WebService that sends a client a DataSet as XML (I use a DataSet.GetXml to get the XML). The DataSet is filled by a DataAdapter in the WebService. The client coverts the XML Back to a DataSet (using StringReader sr = new StringReader(xml); DataSet ds = new DataSet(); ds.ReadXml(sr)). The client then makes changes to this DataSet, and sends the dirty dataset back to the WebService using another GetXml on 'ds'. The...
3
13591
by: JJ | last post by:
Hi, I need to pass a dataset to another win form along with a SqldataAdapter. I don't want to recreate the SqlDataAdapter again either. So to pass to another Win form in my windows form app, do I create the procedure to pass by ref? Which means I don't need to add ByRef because it is defaulted by ref, correct? And in the constructor of the win form that gets created. I need to add in parameters a DataSet and SqlDataAdapter correct? What...
2
1142
by: Steve | last post by:
Hello, Here is my scenario. I have a MDIForm, and 2 Child forms (ChildForm1 and ChildForm2). The child forms can only be opened by their own toolbar icon on the MDIForm. When I open ChildForm1, I have a datagrid that I may want to search for a specific record from time to time. When I want to search for a record, I click on the toolbar for ChildForm2 which basically gives me a textbox for input. Once I click the OK button on ChildForm2, I...
1
1567
by: Wes Hutton via .NET 247 | last post by:
I am trying to pass a data object (set or row) into a functionbyref, and have the same issue either way. In the maincontroller function, I have no issues accessing any parts of mydataset. If I extract a data row, it has values and is fine. However, when I pass either the whole dataset or just a data rowto another function, it errors out, and in the Locals windowjust has "error: cannot obtain value" against every field. I'vecopied the code...
2
1463
by: Bob | last post by:
Hi, Can anyone tell me how to resolve this: I am calling a web service from a WinForm app and passing a typed dataset as a parameter. I have added the dataset to the web service project but I get an error telling me that the WinForm dataset can't be converted to the web service dataset - even though they are exactly the same. How do I get around this? I have tried using CType and DirectCast but always
3
3546
by: GBR | last post by:
I have a collection object inherited from collection base that is used to carry my object entities from server to client through a web service. I want to add a dataset to this collection object and send it across. But when it gets to the web server, its failing. Any help would be abvised? Is this possible? Can I add a dataset object and add it into the collection array and pass it across?
2
2596
by: Carl Heller | last post by:
Working in VS2003, .Net 1.1 I'm working on a project where I compare data between two databases. This is a lengthy process, and very data intensive, so I decided to create a class, and thread out the work. The order of work is as follows: 1. Retrieve the data from primary data source 2. Update UI with retrieved data - this is accomplished by passing a dataset as an event parameter
2
3007
by: zhshqzyc | last post by:
I am going to past a dataset from First.aspx to Second.aspx. A whole table will be displayed on First.aspx and partial columns will be displayed on Second.aspx. First.aspx view in browser works well if I exclude Second.aspx. But when Second.aspx is included in the project, an error happens. I can't find what is wrong in my code. System.NullReferenceException was unhandled by user code Message="Object reference not set to an...
0
844
by: John Sheppard | last post by:
Hello there, I am wanting to pass my datasets by reference to other forms. As soon as I do that I have to reset any binding sources by setting their datasource property to the original datasource. I also find that I cannot then bind directly to my dataset without a binding source, so I have to duplicated all my binding sources on my second form. Is this normal or am I doing something wrong? How do you guys normally pass
4
5931
by: John Sheppard | last post by:
Hello there I was wondering if anyone could help me, I am trying to pass a typed dataset to a dialoged child form by reference. I have binding sources sitting on the child form. So to refresh them I just set their datasource. I am guessing this is probably what is causing the problem. Is there a better way to do this? Anyway this all works happily and things show up when the record already exists but I have 2 problems ; 1) When I add...
0
9454
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
9868
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...
0
8709
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
7242
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
6533
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5139
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...
1
3804
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3352
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2664
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.