DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Tue, 21 Aug 2007 08:52:11 -0700,    posted on: microsoft.public.dotnet.framework.adonet        back       

Thread Index
  1    unknown
          2    Kerry Moorman
          3    unknown
          4    unknown


No updating the table   
Hi,

I am using the following to update some rows in a dataset, I wonder
why the data is no updated in the SQL table. Am I missing anything?
Please advice, your help would be greatly appreciated.

commandTimeoutPeriod = 120;
typeCommand = CommandType.Text;
command.CommandText = commandExecution;
command.Connection = connection;
command.CommandTimeout = commandTimeoutPeriod;
command.CommandType = typeCommand;
SqlDataAdapter adapter = null;

// initialize the adapter and dataset
adapter = new SqlDataAdapter(command);
if( ds == null) ds = new DataSet();
adapter.Fill(ds);

TestData = ds.Tables[ 0 ];

foreach(DataRow record in TestData.Rows)
{
	row["field"] = YES_FLAG;
}
Date:Tue, 21 Aug 2007 08:52:11 -0700   Author:  

RE: No updating the table   
sweetpotatop,

You are not showing any code to update the database. 

One method would be to call the dataadapter's Update method, sending it the 
dataset/datatable as a parameter.

Ofcourse, the dataadapter will need to be supplied with valid Insert, Update 
and Delete commands.

Kerry Moorman

"sweetpotatop@yahoo.com" wrote:


> Hi,
> 
> I am using the following to update some rows in a dataset, I wonder
> why the data is no updated in the SQL table. Am I missing anything?
> Please advice, your help would be greatly appreciated.
> 
> commandTimeoutPeriod = 120;
> typeCommand = CommandType.Text;
> command.CommandText = commandExecution;
> command.Connection = connection;
> command.CommandTimeout = commandTimeoutPeriod;
> command.CommandType = typeCommand;
> SqlDataAdapter adapter = null;
> 
> // initialize the adapter and dataset
> adapter = new SqlDataAdapter(command);
> if( ds == null) ds = new DataSet();
> adapter.Fill(ds);
> 
> TestData = ds.Tables[ 0 ];
> 
> foreach(DataRow record in TestData.Rows)
> {
> 	row["field"] = YES_FLAG;
> }
> 
> 
Date:Tue, 21 Aug 2007 09:26:06 -0700   Author:  

Re: No updating the table   
On Aug 21, 12:26 pm, Kerry Moorman
 wrote:

> sweetpotatop,
>
> You are not showing any code to update the database.
>
> One method would be to call the dataadapter's Update method, sending it the
> dataset/datatable as a parameter.
>
> Ofcourse, the dataadapter will need to be supplied with valid Insert, Update
> and Delete commands.
>
> Kerry Moorman
>
>
>
> "sweetpota...@yahoo.com" wrote:
> > Hi,
>
> > I am using the following to update some rows in a dataset, I wonder
> > why the data isnoupdatedin the SQL table. Am I missing anything?
> > Please advice, your help would be greatly appreciated.
>
> > commandTimeoutPeriod = 120;
> > typeCommand = CommandType.Text;
> > command.CommandText = commandExecution;
> > command.Connection = connection;
> > command.CommandTimeout = commandTimeoutPeriod;
> > command.CommandType = typeCommand;
> > SqlDataAdapter adapter = null;
>
> > // initialize the adapter and dataset
> > adapter = new SqlDataAdapter(command);
> > if( ds == null) ds = new DataSet();
> > adapter.Fill(ds);
>
> > TestData = ds.Tables[ 0 ];
>
> > foreach(DataRow record in TestData.Rows)
> > {
> >    row["field"] = YES_FLAG;
> > }- Hide quoted text -
>
> - Show quoted text -


I have been trying to use
adapter.update(ds, "mytable") however, I got an error
"Update requires a valid UpdateCommand when passed DataRow collection
with modified rows"

The think is I can't use the update command, I would like to do
something like this, is it possible?

 foreach(DataRow record in TestData.Rows)
 {
   row["field"] = YES_FLAG;
 }
 update(ds, "mytable")
Date:Tue, 21 Aug 2007 10:28:31 -0700   Author:  

Re: No updating the table   
On Aug 21, 1:28 pm, sweetpota...@yahoo.com wrote:

> On Aug 21, 12:26 pm, Kerry Moorman
>
>
>
>
>
>  wrote:
> >sweetpotatop,
>
> > You are not showing any code to update the database.
>
> > One method would be to call the dataadapter's Update method, sending it the
> > dataset/datatable as a parameter.
>
> > Ofcourse, the dataadapter will need to be supplied with valid Insert, Update
> > and Delete commands.
>
> > Kerry Moorman
>
> > "sweetpota...@yahoo.com" wrote:
> > > Hi,
>
> > > I am using the following to update some rows in a dataset, I wonder
> > > why the data isnoupdatedin the SQL table. Am I missing anything?
> > > Please advice, your help would be greatly appreciated.
>
> > > commandTimeoutPeriod = 120;
> > > typeCommand = CommandType.Text;
> > > command.CommandText = commandExecution;
> > > command.Connection = connection;
> > > command.CommandTimeout = commandTimeoutPeriod;
> > > command.CommandType = typeCommand;
> > > SqlDataAdapter adapter = null;
>
> > > // initialize the adapter and dataset
> > > adapter = new SqlDataAdapter(command);
> > > if( ds == null) ds = new DataSet();
> > > adapter.Fill(ds);
>
> > > TestData = ds.Tables[ 0 ];
>
> > > foreach(DataRow record in TestData.Rows)
> > > {
> > >    row["field"] = YES_FLAG;
> > > }- Hide quoted text -
>
> > - Show quoted text -
>
> I have been trying to use
> adapter.update(ds, "mytable") however, I got an error
> "Update requires a valid UpdateCommand when passed DataRow collection
> with modified rows"
>
> The think is I can't use the update command, I would like to do
> something like this, is it possible?
>
>  foreach(DataRow record in TestData.Rows)
>  {
>    row["field"] = YES_FLAG;
>  }
>  update(ds, "mytable")- Hide quoted text -
>
> - Show quoted text -



Since I will be updating different field values of a datarow from
different part of the source, code, I wonder if I can do this without
using the "UPDATE table SET field = value" . I hope I would wrap up
the update by simply using update(ds, "mytable"), I remember I can do
this in my past project, just wondering why I can't do it now.

Thanks
Date:Tue, 21 Aug 2007 11:22:20 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us