DataAdpater Without SqlCommand

G

Guest

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?
 
G

Guest

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
 
G

Guest

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 = getDataSetFromBusnLayer()

da.Fill(ds, 0)

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

Dim cb As New SqlCommandBuilder(da)
da.UpdateCommand = cb.GetUpdateCommand
da.Update(ds, 0)
 
G

Guest

Billy,
Just remove the line:
da.Fill(ds,0)

-- your DataSet is already filled, because you got it from the
getDataSetFromBusLayer() 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
 
G

Guest

If i follow your logic correctly, the below code should work, but it throws
me a "The DataAdapter.SelectCommand property needs to be initialized." error?

-----------------------------------
Dim ds As Dataset
ds = getDataSetFromBusnLayer()

Dim da As New SqlDataAdapter
Dim cb1 As New SqlCommandBuilder(da)
da.UpdateCommand = cb1.GetUpdateCommand
da.Update(ds, 0)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top