CSharp/C# >> adapter updates

by DaveL » Mon, 08 Sep 2008 22:54:53 GMT

c# 2.0, etc, sql server 2005

i have a situation where i will be joing 3 tables in a proc
to return a row set of data to be verified by a windows service.

example:
Select m.TransactionId, m.Statusid,m.Field1,m.Field2,c1.field1,c2.field2
from myMaster m (nolock)
join child1 c1 (nolock) on c1.rowid = m.rowid
join child2 c2 (nolock) on c2.rowid =c1.rowid
where m.TransactionId = 99999999

the above is in a Proc.....along with the columns being returnd. When a
invalid row is determined
i will be changing a Statusid to be updated back at the server

i want to issue a SqlAdapter.update() , but i believe sqlAdapter does not
work for this type of Returnd row set...

so i was thinking of returning a second rows set with the transactionid and
statusid of the mymaster table this is all that needs to be updated

so a Additional select will be involved, and my windows service will
validate rowset 1 and update rowset 2 for updating the actual table
with a sqladapter update

Example
--// data to be validated
Select m.transactionId,m.Field1,m.Field2,c1.field1,c2.field2 from myMaster
m (nolock)
join child1 c1 (nolock) on c1.rowid = m.rowid
join child2 c2 (nolock) on c2.rowid =c1.rowid
where m.TransactionId = 99999999

// used with sqldataAdapter on return of data to mymaster table
select m.TransactionId,m.Statusid from mymaster (nolock) where
m.transactionid= 99999999

//i could have up to 5000 rows, and want to do a batch update instead of
some other slow update

Your thoughts please
Thanks
DaveL





Similar Threads

1. Data adapter.Update with fields that are part of the update condit - ADO.Net

2. Data adapter.Update with fields that are part of the update co

Hi,

THIS IS an absolute satisfactory answer ! thanks a lot... nothing like being 
a "crack" as you... thanks again.

p.d.: I love managed newsgroups 8-D ; I hope someday I could help others as 
you so easily...

-- 
Roger Tranchez
.NET 2005 and DB developer


"RobinS" wrote:

> You are setting code to the original version in both cases. You need to use 
> different parameters, one for codi in the SET clause, and one for codi in 
> the WHERE clause. Same for data_peticio.  The one in the WHERE clause 
> should be DataRowVersionOriginal, the other one needs to be 
> ModifiedCurrent.
> Robin S.
> ---------------------------------------
> "Roger Tranchez" < XXXX@XXXXX.COM > wrote in message 
> news: XXXX@XXXXX.COM ...
> > Hello,
> >
> > I'm trying to update some records of a database table called
> > "PETICIONS_TRESORERIA" with this structure:
> >
> > codi        int
> > data_peticio datetime
> > name            varchar
> >
> > (first two fields made the primary key)
> > .
> > .
> > .
> > I'm using a data adapter with a UpdateCommand as follows:
> >
> > update PETICIONS_TRESORERIA set
> > codi=@codi,data_peticio=@data_peticio,name=@name where codi=@codi and
> > data_peticio=@data_peticio
> >
> > The "SourceVersion" property for the UpdateCommand parameters @codi and
> > @data_peticio, are set to "DataRowVersion.Original", as if the user 
> > change
> > them on the associated datagrid , I want to return the original values 
> > for
> > changing them
> >
> > An example will be more clear:
> >
> > If I have these original values for codi, data_peticio and name :
> >
> > 1000,1/1/2007,Roger
> >
> > And I change the "name" to other value, when I do the data adapter 
> > update,
> > it works perfect, but, if I change the code or data_peticio, nothing 
> > happens
> > (no errors, no update).
> >
> > The same happens if I undo the definition of the primary key on the 
> > table.
> >
> > What's the problem ?
> >
> >
> > Thanks in advance,
> >
> >
> > Roger Tranchez
> > .NET 2005 and DB developer 
> 
> 
> 

3. Adapter.Update C# buffer size

4. Why isn't my data adapter updating?

I've got a simple windows form with some bound textboxes 
and Save button. Each texbox is bound to column in a table 
in an Access database. The form fills fine - all the 
fields show the correct data for the record I load.  So 
then I change the contents of one of the textboxes and 
click on the Save button. The button's event handler then 
calls the data adapter's Update method and I check the 
return value.  Nada-zilch-nothing. I even put a breakpoint 
there, dug into the DataSet in the debugger and found the 
DataRow in question.  Sure enough, there is my changed 
data but RowState is showing Unchanged. The documentation 
("Introduction to DataSet Updates") says: "In Windows 
Forms, the data-binding architecture takes care of sending 
changes from data-bound controls to the dataset, and you 
do not have to explicitly update the dataset with your own 
code."  Sounds pretty clear to me but obviously it's not 
working the way I think it should. What am I missing??




5. data adapter update autoincremented primary key value - CSharp/C#

6. Calling Adapter.Update(DataTable) in succession causes DBConcurrencyException

7. Another adapter.update not working - ADO.Net

8. adapter.Update question ??

Dear all,

I have an application sQL statement which call an SQL view. The return 
dataset from the View is bind to a WinForm datagriview control.
From this datcontrol, data can be edited and updated.

What I woul like to get is that this modification goes back to the View at 
SQL server side which will then update proper table.

The call method which will get that modification back is done as follow :
=====>

 public static Boolean UpdateAlarm(string ConnectionString,DataSet dsSource)
            {
                               
                //Connection definition
                using (SqlConnection sqlConnection = new 
SqlConnection(ConnectionString))
                {
                    // Request Definition
                    using (SqlCommand sqlcommand = new SqlCommand())
                    {
                        sqlcommand.Connection = sqlConnection;
                        sqlcommand.CommandType = System.Data.CommandType.Text;
                        sqlcommand.CommandText = "Select * from 
v_Current_Alarm";

                        try
                        {
                            sqlConnection.Open();
                            SqlDataAdapter adapter = new 
SqlDataAdapter(sqlcommand);
                            
adapter.Update(dsSource,dsSource.Tables[0].TableName);  
                            sqlConnection.Close();

                        }
<===

What is strange from that is that if I Watch the dsSource object, 
modification are seen inside Rows.ItemArray, but the RowsState is set to 
"Unchanged"

Then my Update function of Adapter seems to not modiy anything on the back 
end database.

Any ideas what I do wrong ?

regards
serge