[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Eyal

8/13/2002 1:14:00 AM

Hello,

I've been struggling for a while with a small problem,
which has to do with updating a data source table, while
working with a dataset.

I have a database table with product information that I
want to display one-by-one and allow the user to update,
delete or insert a new row into.

The problem comes in when I try to do that from a SQL View
object. The view formats the necessary values, which
populate the dataset (via DataAdapter.Fill).

I want to write a method that will update a row that had
been changed (in the data source table) and will reflect
the changes in the data set accordingly.

A helpful member of the newsgroup suggested I use the
UpdateCommand of the DataAdapter, but after researching it
a bit, I feel that I have more questions now.

I read the following article:
http://msdn.microsoft.com/library/de...
url=/library/en-
us/cpguide/html/cpconupdatingdatabasewithdataadapterdataset
.asp


The article explains how to update a row by using the
updateCommand. It gives an example of an update command
that uses sql parameters.

Ex.
------------------
catDA.UpdateCommand = New SqlCommand("UPDATE Categories
SET CategoryName = @CategoryName " & _
"WHERE CategoryID =
@CategoryID", nwindConn)

-----------------------



My questions now are;
1. Does this update the data source? Dataset? Both?

2. If I have several columns that are generated by the
view, will the dataset update the data based on the values
I specify per column or directly from the view?

Ex. I have a column that calculates the value of markup
for an item. the user changes the markup type (by
category, by product values...) . .based on that, the
database view will generate a different markup value. will
that reflect appropriately?

3. Am I limited to only one UpdateCommand in the
dataAdapter? Will that command have to hold all updateable
parameters in one command? Or can I have several commands
for different data values.

4. If I need to use one command for all values, how do I
avoid NULL values?

I hope this is not to much to ask for help on... I've been
running around this problem for a couple of weeks and I
try not to resort to the newsgroups until I look
everywhere else.

Any help is greatly appreciated!
- Eyal.

1 Answer

Chirag Gupta

9/5/2002 2:50:00 AM

0

My suggestion would be to use ExecuteSQLQuery command.
That way you can really control this very well. Use of
DataSet and DataViews is very limited.

After updating the data you might wanna refresh your
dataset also.

I hope this helps.
>-----Original Message-----
>Hello,
>
>I've been struggling for a while with a small problem,
>which has to do with updating a data source table, while
>working with a dataset.
>
>I have a database table with product information that I
>want to display one-by-one and allow the user to update,
>delete or insert a new row into.
>
>The problem comes in when I try to do that from a SQL
View
>object. The view formats the necessary values, which
>populate the dataset (via DataAdapter.Fill).
>
>I want to write a method that will update a row that had
>been changed (in the data source table) and will reflect
>the changes in the data set accordingly.
>
>A helpful member of the newsgroup suggested I use the
>UpdateCommand of the DataAdapter, but after researching
it
>a bit, I feel that I have more questions now.
>
>I read the following article:
>http://msdn.microsoft.com/library/de...
>url=/library/en-
>us/cpguide/html/cpconupdatingdatabasewithdataadapterdatase
t
>..asp
>
>
>The article explains how to update a row by using the
>updateCommand. It gives an example of an update command
>that uses sql parameters.
>
>Ex.
>------------------
>catDA.UpdateCommand = New SqlCommand("UPDATE Categories
>SET CategoryName = @CategoryName " & _
> "WHERE CategoryID =
>@CategoryID", nwindConn)
>
>-----------------------
>
>
>
>My questions now are;
>1. Does this update the data source? Dataset? Both?
>
>2. If I have several columns that are generated by the
>view, will the dataset update the data based on the
values
>I specify per column or directly from the view?
>
>Ex. I have a column that calculates the value of markup
>for an item. the user changes the markup type (by
>category, by product values...) . .based on that, the
>database view will generate a different markup value.
will
>that reflect appropriately?
>
>3. Am I limited to only one UpdateCommand in the
>dataAdapter? Will that command have to hold all
updateable
>parameters in one command? Or can I have several commands
>for different data values.
>
>4. If I need to use one command for all values, how do I
>avoid NULL values?
>
>I hope this is not to much to ask for help on... I've
been
>running around this problem for a couple of weeks and I
>try not to resort to the newsgroups until I look
>everywhere else.
>
>Any help is greatly appreciated!
>- Eyal.
>
>.
>