updating datasource using 3-tier architecture

R

Raghav

Hi,

I am retrieveing the data from 2 table (MAster Detail) to the winform
and displaying on winform in a grid view.User should have an uption to
update the rows.So There is a button Update wen ever a person clicks
that DataSource needs to be updated.What i did is in Winforms for
displaying the data i have a dataset.So wenever user clicks the update
button here is what i am doing:

BindingContext[dsAdmin, "MasterMovie"].EndCurrentEdit();
BindingContext[dsAdmin, "Show"].EndCurrentEdit();
Adminshow as1 = new Adminshow();
dsAdmin2 = as1.updateData(dsAdmin);

I am passing the whole dataset to dataaccess layer.


In Data Access Layer:
public DataSet UpdateData(DataSet ds2)


{
SqlCommand cmd1 = new SqlCommand("INSERT INTO [Show]
([TheatreID], [MovieID], [Date], [NumberOfShows], [ShowTimes])" +
" VALUES (@TheatreID, @MovieID, @Date,
@NumberOfShows, @ShowTimes)", conn);

dashow1 = new SqlDataAdapter(cmd1);


SqlCommandBuilder cmb = new SqlCommandBuilder(dashow1);
DataSet ds7 = new DataSet();
ds7=ds2;

dashow1.Update(ds7, "Show");

ds7.AcceptChanges();
return ds7;
}


In BusinessLogic Layer i am just capturing this and passing it to
Winform.


But wen i close the WinForm and relod the table data again..Its still
showing the old Data not the updated one?I am not getting any error
also..

Please let me know how to go about this...


Thanks,
Raghav
 
C

Cor Ligthert[MVP]

Raghav,

I hope you don't sent the whole dataset to the dataAccess layer but only its
reference by value.
(What you are in fact doing, however a lot to much code which I don't
understand why that is)

Normally is the dataset that you use in your UI and in the DataLayer the
same one.
(In both it is just a reference that points to an object on the managed
heap)

Cor
 

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

Similar Threads


Top