473,746 Members | 2,702 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataAdpater Without SqlCommand

My Busn tier returns a DataSet and I want to fill a DataAdapter in the
presentation layer with that dataset.
Problem is that if I create a DataAdapter in the presentation layer i need
to specify a SqlCommand with it, but i don't want to, i just want to fill it
with the DataSet from the Busn Tier.

Any ideas on how you get round this?

Feb 6 '06 #1
4 1337
Billy,
The general purpose of a DataAdapter is to fil a DataTable or DataSet
(besides updates, etc). So, if you've already got a filled dataset from
somewhere else, you should not need a DataAdapter for anything.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Billy" wrote:
My Busn tier returns a DataSet and I want to fill a DataAdapter in the
presentation layer with that dataset.
Problem is that if I create a DataAdapter in the presentation layer i need
to specify a SqlCommand with it, but i don't want to, i just want to fill it
with the DataSet from the Busn Tier.

Any ideas on how you get round this?

Feb 6 '06 #2
I do need to update the dataset, here is my code if that helps:
I think i maybe trying to go about this the wrong way?

----------------------------
Dim ds As Dataset
Dim da As New SqlDataAdapter

ds = getDataSetFromB usnLayer()

da.Fill(ds, 0)

ds.Tables(0).Ro ws(objArgs.Item .ItemIndex(0) = "NewValue"

Dim cb As New SqlCommandBuild er(da)
da.UpdateComman d = cb.GetUpdateCom mand
da.Update(ds, 0)
---------------------------------
"Peter Bromberg [C# MVP]" wrote:
Billy,
The general purpose of a DataAdapter is to fil a DataTable or DataSet
(besides updates, etc). So, if you've already got a filled dataset from
somewhere else, you should not need a DataAdapter for anything.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Billy" wrote:
My Busn tier returns a DataSet and I want to fill a DataAdapter in the
presentation layer with that dataset.
Problem is that if I create a DataAdapter in the presentation layer i need
to specify a SqlCommand with it, but i don't want to, i just want to fill it
with the DataSet from the Busn Tier.

Any ideas on how you get round this?

Feb 6 '06 #3
Billy,
Just remove the line:
da.Fill(ds,0)

-- your DataSet is already filled, because you got it from the
getDataSetFromB usLayer() method.

You can create a new dataapter at any time, set the commands, and pass in a
dataset and call the adapter's Update method.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Billy" wrote:
I do need to update the dataset, here is my code if that helps:
I think i maybe trying to go about this the wrong way?

----------------------------
Dim ds As Dataset
Dim da As New SqlDataAdapter

ds = getDataSetFromB usnLayer()

da.Fill(ds, 0)

ds.Tables(0).Ro ws(objArgs.Item .ItemIndex(0) = "NewValue"

Dim cb As New SqlCommandBuild er(da)
da.UpdateComman d = cb.GetUpdateCom mand
da.Update(ds, 0)
---------------------------------
"Peter Bromberg [C# MVP]" wrote:
Billy,
The general purpose of a DataAdapter is to fil a DataTable or DataSet
(besides updates, etc). So, if you've already got a filled dataset from
somewhere else, you should not need a DataAdapter for anything.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Billy" wrote:
My Busn tier returns a DataSet and I want to fill a DataAdapter in the
presentation layer with that dataset.
Problem is that if I create a DataAdapter in the presentation layer i need
to specify a SqlCommand with it, but i don't want to, i just want to fill it
with the DataSet from the Busn Tier.

Any ideas on how you get round this?

Feb 6 '06 #4
If i follow your logic correctly, the below code should work, but it throws
me a "The DataAdapter.Sel ectCommand property needs to be initialized." error?

-----------------------------------
Dim ds As Dataset
ds = getDataSetFromB usnLayer()

Dim da As New SqlDataAdapter
Dim cb1 As New SqlCommandBuild er(da)
da.UpdateComman d = cb1.GetUpdateCo mmand
da.Update(ds, 0)
------------------------------------

"Peter Bromberg [C# MVP]" wrote:
Billy,
Just remove the line:
da.Fill(ds,0)

-- your DataSet is already filled, because you got it from the
getDataSetFromB usLayer() method.

You can create a new dataapter at any time, set the commands, and pass in a
dataset and call the adapter's Update method.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Billy" wrote:
I do need to update the dataset, here is my code if that helps:
I think i maybe trying to go about this the wrong way?

----------------------------
Dim ds As Dataset
Dim da As New SqlDataAdapter

ds = getDataSetFromB usnLayer()

da.Fill(ds, 0)

ds.Tables(0).Ro ws(objArgs.Item .ItemIndex(0) = "NewValue"

Dim cb As New SqlCommandBuild er(da)
da.UpdateComman d = cb.GetUpdateCom mand
da.Update(ds, 0)
---------------------------------
"Peter Bromberg [C# MVP]" wrote:
Billy,
The general purpose of a DataAdapter is to fil a DataTable or DataSet
(besides updates, etc). So, if you've already got a filled dataset from
somewhere else, you should not need a DataAdapter for anything.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Billy" wrote:

> My Busn tier returns a DataSet and I want to fill a DataAdapter in the
> presentation layer with that dataset.
> Problem is that if I create a DataAdapter in the presentation layer i need
> to specify a SqlCommand with it, but i don't want to, i just want to fill it
> with the DataSet from the Busn Tier.
>
> Any ideas on how you get round this?
>

Feb 6 '06 #5

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

Similar topics

10
18536
by: Henrik Dahl | last post by:
Hello! After I've finished using an instance of the SqlCommand class, should I then invoke Dispose() on the instance. I suppose so, as there is a Dispose method, but what does it actually release? I would basically prefer to skip invoking Dispose() as this will free me from determining when the usage actually has finished.
3
2414
by: Paulb1us | last post by:
I want to update records from a csv file. I do this in a button click: //Create Adapters da = new OdbcDataAdapter("Select * FROM test.csv", conn); //Fill a data table da.Fill(dt);
0
2479
by: J. Miller | last post by:
I have a datagrid with update/cancel on one side, a button on the other which, when clicked, will take the user to a page that allows them to e-mail that particular observation's data. My problem, is that I have some columns that are sortable. To make everything work, I can wrap the e-mail code in a 'if not.postback' statement (wrong I know--testing here), but then, my sorts/updates/cancels don't work because an error is thrown from the...
1
5594
by: Tom | last post by:
Hello guys Please have a look on following paragraph from ".NET Data Access Architecture Guide". ''''''''''' Although you can repeatedly use the same SqlCommand object to execute the same command multiple times, do not reuse the same SqlCommand object to execute different commands. 1) You do not need to explicitly open or close the database connection. The SqlDataAdapter Fill method opens the database connection and then closes the...
3
3857
by: Jason Huang | last post by:
Hi, In C#.Net, can we have more than one SqlCommand in a SqlConnection? And in one SqlCommand, can we have more than one SqlDataReader in a SqlCommand? In what situation should I use SqlConneciton.Dispose() instead of SqlConnection.Close()? Thanks for help.
0
1172
by: Agnes | last post by:
I got a silly question about Sqlcommand . In my form, there are 5 methods which use the same sqlcommand to execute reader. I had create and dispose for each sqlcommand in every method. Some said that I can only delcare one sqlcommand and re-use it in every method and no need to dispose until form closed. I am wonder which approach is correct. public class myform Dim cmdSearch As New SqlClient.SqlCommand method 1
1
7255
by: job | last post by:
how is it possible to serialize/de-serialize a SqlCommand?
1
1876
by: Sin Jeong-hun | last post by:
I need to programatically change the SelectCommand of an SqlDataSource. When I query I use SqlCommand and all the character escaping is automatically done with SqlCommand.Parameters.Add(); Now, since SelectCommand property is just a text, I need to manually do the character escaping. Is there any other built-in query builder that I can use in this situation?
6
2957
by: Frank Hauptlorenz | last post by:
Hello, I'm trying to send an SqlCommand to a WCF-Service. For this I'm using the following DataContract: public class SqlCommandComposite { SqlCommand cmd = new SqlCommand();
0
8974
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
8800
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9508
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9350
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
9218
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6060
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
4586
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
4836
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.