Re: How to refresh a datatable??
- From: "W.G. Ryan eMVP" <WilliamRyan@xxxxxxxxx>
- Date: Tue, 3 May 2005 14:32:42 -0400
> 1. Want to ask you If I do correctly????
>From the looks of everything, it looks ok
> 2. Now Everytime when i want to add a new 'row' to the table
IncomeProducts,
>From the looks of how this is set up, you have two options. One is that you
can store the Datatable in session or viewstate, and each times someone
makes an addition, add a datarow to the datatable with the new information.
When they are done with all of their editing, you can pass the datatable to
an adapter configured to handle the update. Or, each time you can call
update. In most cases you'll probably want to opt for the latter. Assuming
that your update is successful, the database and the local datatable should
look the same with the exception of new rows added/deleted/modified by other
users. If this isn't a problem, then you don't need to requery the database
b/c the datatable and the database will match as soon as you fire the
update. If you absolutely needed to have the data match and knew that you
didn't want to overwrite any data that was changed by someone else, the
safest way to do it is check for new data with a new select and repopulate.
There are a few ways to go about this but this is what you are trying to
avoid right?
Anway, by just submitting your updates your table and db will match as long
as no exceptions are raised so I think you're good to go.
If I misunderstood what you were asking though or didn't answer your
question to your satisfaction, please let me know.
Cheers,
Bill
--
W.G. Ryan, MVP
www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"Alex" <chipheo2k@xxxxxxx> wrote in message
news:eeSt7LAUFHA.612@xxxxxxxxxxxxxxxxxxxxxxx
> Hello!
> I have a small prob, so pls help me to solve it.
> I have 2 tables
> Products(ProductID, ProductName, Price)
> Stores(StoreID, StoreName)
> now I must design a table for Income-Product: IncomeProducts(id, Date ,
> ProductID, Quantity, Price, Total, StoreID).
> But I want to display the table IncomeProducts in the DataGrid like that :
> | ProductName | Price | Quantity | Total | StoreName
> To do it: I use VIEW to make a visual Table (IncomeProductView):
> SELECT dbo.IncomeProducts.[Date],
> dbo.Products.ProductName,dbo.IncomeProducts.Price,
> dbo.IncomeProducts.Quantity,
dbo.IncomeProducts.Total,
> dbo.Stores.StoreName
> FROM dbo.IncomeProducts INNER JOIN
> dbo.Products ON dbo.IncomeProducts.ProductID =
> dbo.Products.ProductID INNER JOIN
> dbo.Stores ON dbo.IncomeProducts.StoreID =
> dbo.Stores.StoreID
>
>
>
>
> And now I display this View on the DataGrid
> ...
> SqlDataAdapter sda..
> DataSet ds
> sda.Fill(ds, "IncomeProductView");
> DataGrid dg;
> dg.DataSource = ds.Tables["IncomeProductView"];
> ....
>
> 1. Want to ask you If I do correctly????
> I want it to be displayed in the DataGrid ( to do that, the View must
> refresh to get the new inserted row). How can I do it???? or I must Clear
> the ds and "Download" again??? It's very bad......
>
>
> Thanks
>
>
.
- Follow-Ups:
- Re: How to refresh a datatable??
- From: Alex
- Re: How to refresh a datatable??
- References:
- How to refresh a datatable??
- From: Alex
- How to refresh a datatable??
- Prev by Date: Re: Lightweight Dataset
- Next by Date: Re: Newbee question.
- Previous by thread: How to refresh a datatable??
- Next by thread: Re: How to refresh a datatable??
- Index(es):
Relevant Pages
|