473,396 Members | 1,756 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,396 software developers and data experts.

Please help !

I have a function defined In a Class1.

Ex

Public Class1

Public Function GetData () as DataSet

******** Using SqlDatAdapter I fill the DataSet

******** It will return the Filled DataSet.

End Function

End Class

I have another Class which calls the GetData function of the first class.

Public Class2

Public Function UdateDatasetTODataBase()

Create Instance of the First class and Call the
GetData Function, which returns the DataSet.

'''''''' I want To Add/Update the Dataset and
reflect back to DataBase.. ****** How to Do this?????????????

End function

End Class

Using SqlDataAdapter this can be Done only if u fill the Dataset in the Same
Function, make Changes and Call the SqlDataAdapters Update method,

But I am filling the Dataset in Different function..

Is there anyway to assign already filled Dataset to SqlDataAdapter ?

TIA,

Gary
Nov 20 '05 #1
2 2054
Hi Gary,
You would need to either have a DataAdapter in your second class or expose
it as public on the first class but if you do you can update fine. One
thing that's not very apparent though is that you should do a Merge to get
the dataset into the second class otherwise you can end up with some
strange reference issues. The code would look something like this:

Public Class2
Public Function UdateDatasetTODataBase()
Dim c1 as New Class1

'get the dataset by merging it into a new dataset for
reference issues
Dim ds as new DataSet
ds.Merge(c1.GetData)

'do anything else you would like with the dataset

'update it with a new data adapter
DataAdapter.Update(ds)

'or update it with the public adapter on class1
c1.DataAdapter.Update(ds)
End function
End Class

Hope this helps,
Eric - VB.Net team
--------------------
| From: "Gary" <ms****@microsoft.com>
| Subject: Please help !
| Date: Wed, 24 Sep 2003 18:25:03 +0530
|
| I have a function defined In a Class1.
|
| Ex
|
| Public Class1
|
| Public Function GetData () as DataSet
|
| ******** Using SqlDatAdapter I fill the DataSet
|
| ******** It will return the Filled DataSet.
|
| End Function
|
| End Class
|
|
|
| I have another Class which calls the GetData function of the first class.
|
| Public Class2
|
| Public Function UdateDatasetTODataBase()
|
| Create Instance of the First class and Call the
| GetData Function, which returns the DataSet.
|
| '''''''' I want To Add/Update the Dataset and
| reflect back to DataBase.. ****** How to Do this?????????????
|
| End function
|
| End Class
|
|
|
| Using SqlDataAdapter this can be Done only if u fill the Dataset in the
Same
| Function, make Changes and Call the SqlDataAdapters Update method,
|
| But I am filling the Dataset in Different function..
|
| Is there anyway to assign already filled Dataset to SqlDataAdapter ?
|
| TIA,
|
| Gary
|
|
|

Nov 20 '05 #2
Hi Gary,

I'm not sure, but you'd think there would be a way to do this - however, 2
points:

1. post this question to microsoft.public.dotnot.framework.adonet
2. why not build the dataset with the dataadapter in function getdata and
pass back the sqldataadapter as well as the dataset (pass by reference)?
Then they would be in sync.

HTH,

Bernie Yaeger

"Gary" <ms****@microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I have a function defined In a Class1.

Ex

Public Class1

Public Function GetData () as DataSet

******** Using SqlDatAdapter I fill the DataSet

******** It will return the Filled DataSet.

End Function

End Class

I have another Class which calls the GetData function of the first class.

Public Class2

Public Function UdateDatasetTODataBase()

Create Instance of the First class and Call the
GetData Function, which returns the DataSet.

'''''''' I want To Add/Update the Dataset and
reflect back to DataBase.. ****** How to Do this?????????????

End function

End Class

Using SqlDataAdapter this can be Done only if u fill the Dataset in the Same Function, make Changes and Call the SqlDataAdapters Update method,

But I am filling the Dataset in Different function..

Is there anyway to assign already filled Dataset to SqlDataAdapter ?

TIA,

Gary

Nov 20 '05 #3

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

Similar topics

1
by: Numberwhun | last post by:
Hello everyone! I am trying to learn java and have run into kind of a snag. Here is the code that I have so far: ------ <begin_code> ---------- import javax.swing.*; import...
1
by: HolaGoogle | last post by:
Hi all, Please help me with the following..it's realy urgent and i tried everything i could and i can't get it work properly!! Thanks in advance. Here's what i'm trying to accomplish: in my...
0
by: s_erez | last post by:
Hi, This is a realy tricky one. I have an ASP.NET application where some pages are reading data from a DB and presenting reports. In order for the user to wait while the page is reading data from...
2
by: rked | last post by:
I get nameSPAN1 is undefined when I place cursor in comments box.. <%@ LANGUAGE="VBScript" %> <% DIM ipAddress ipAddress=Request.Servervariables("REMOTE_HOST") %> <html> <head> <meta...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
4
by: pshindle | last post by:
DB2 Team - I just downloaded and unzipped the new Fixpack 9 for DB2 ESE V8 for Windows (FP9_WR21350_ESE.exe). I then burned the unzipped Fixpack files to a CD. I proceded to install this...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
1
PEB
by: PEB | last post by:
POSTING GUIDELINES Please follow these guidelines when posting questions Post your question in a relevant forum Do NOT PM questions to individual experts - This is not fair on them and...
4
by: fatboySudsy | last post by:
Hi, I have constructed a client program that has given me some error codes that i just cannot see. I was wondering if a different set of eyes with much more experience than me could help me out. ...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
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...

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.