Hi,
I am using a SqlCommandBuild er to update a Db table via an updated DataSet
and SqlAdapter and it doesn't seem to be generating the activity commands
from the Select command. Here is a snippet.
sda = new SqlDataAdapter( );
sda.SelectComma nd = new SqlCommand(sql, dbcon);
SqlCommandBuild er scb = new SqlCommandBuild er(sda);
DataSet ds = new DataSet();
sda.Fill(ds,pag eName);
DataRow dr = ds.Tables[pageName].NewRow();
for(int x=0;x<14;x++)
{
dr[x] = newDataRow[x];
}
ds.Tables[pageName].Rows.Add(dr);
ds.AcceptChange s();
sda.Update(ds,p ageName);
Nothing happens, no update and no exceptions. Any ideas please?
Jim 4 2132
Yes - you called AcceptChanges. This changes the states of all the rows to
unmodified. So when you go to update, it looks like there is nothing to
update.
Why call AcceptChanges to change all the row states if you then want to
update?
"Jim Reynolds" <Ji*********@di scussions.micro soft.com> wrote in message
news:F0******** *************** ***********@mic rosoft.com... Hi, I am using a SqlCommandBuild er to update a Db table via an updated DataSet and SqlAdapter and it doesn't seem to be generating the activity commands from the Select command. Here is a snippet.
sda = new SqlDataAdapter( ); sda.SelectComma nd = new SqlCommand(sql, dbcon); SqlCommandBuild er scb = new SqlCommandBuild er(sda);
DataSet ds = new DataSet(); sda.Fill(ds,pag eName);
DataRow dr = ds.Tables[pageName].NewRow();
for(int x=0;x<14;x++) { dr[x] = newDataRow[x]; } ds.Tables[pageName].Rows.Add(dr); ds.AcceptChange s(); sda.Update(ds,p ageName);
Nothing happens, no update and no exceptions. Any ideas please?
Jim
Doh!
Thanks very much Marina. Why would you need to call AcceptChanges on a
DataSet?
Jim
"Marina" wrote: Yes - you called AcceptChanges. This changes the states of all the rows to unmodified. So when you go to update, it looks like there is nothing to update.
Why call AcceptChanges to change all the row states if you then want to update?
"Jim Reynolds" <Ji*********@di scussions.micro soft.com> wrote in message news:F0******** *************** ***********@mic rosoft.com... Hi, I am using a SqlCommandBuild er to update a Db table via an updated DataSet and SqlAdapter and it doesn't seem to be generating the activity commands from the Select command. Here is a snippet.
sda = new SqlDataAdapter( ); sda.SelectComma nd = new SqlCommand(sql, dbcon); SqlCommandBuild er scb = new SqlCommandBuild er(sda);
DataSet ds = new DataSet(); sda.Fill(ds,pag eName);
DataRow dr = ds.Tables[pageName].NewRow();
for(int x=0;x<14;x++) { dr[x] = newDataRow[x]; } ds.Tables[pageName].Rows.Add(dr); ds.AcceptChange s(); sda.Update(ds,p ageName);
Nothing happens, no update and no exceptions. Any ideas please?
Jim
If you used GetChanges to get just the changes, and after the save was done,
you wanted to reset all the rows to unchanged, to match.
Or if you had application logic the required you for some reason to want
this to happen.
"Jim Reynolds" <Ji*********@di scussions.micro soft.com> wrote in message
news:6C******** *************** ***********@mic rosoft.com... Doh!
Thanks very much Marina. Why would you need to call AcceptChanges on a DataSet?
Jim
"Marina" wrote:
Yes - you called AcceptChanges. This changes the states of all the rows to unmodified. So when you go to update, it looks like there is nothing to update.
Why call AcceptChanges to change all the row states if you then want to update?
"Jim Reynolds" <Ji*********@di scussions.micro soft.com> wrote in message news:F0******** *************** ***********@mic rosoft.com... > Hi, > I am using a SqlCommandBuild er to update a Db table via an updated > DataSet > and SqlAdapter and it doesn't seem to be generating the activity > commands > from the Select command. Here is a snippet. > > sda = new SqlDataAdapter( ); > sda.SelectComma nd = new SqlCommand(sql, dbcon); > SqlCommandBuild er scb = new SqlCommandBuild er(sda); > > DataSet ds = new DataSet(); > sda.Fill(ds,pag eName); > > DataRow dr = ds.Tables[pageName].NewRow(); > > for(int x=0;x<14;x++) > { > dr[x] = newDataRow[x]; > } > ds.Tables[pageName].Rows.Add(dr); > ds.AcceptChange s(); > sda.Update(ds,p ageName); > > Nothing happens, no update and no exceptions. Any ideas please? > > Jim
Thanks very much.
"Marina" wrote: If you used GetChanges to get just the changes, and after the save was done, you wanted to reset all the rows to unchanged, to match.
Or if you had application logic the required you for some reason to want this to happen.
"Jim Reynolds" <Ji*********@di scussions.micro soft.com> wrote in message news:6C******** *************** ***********@mic rosoft.com... Doh!
Thanks very much Marina. Why would you need to call AcceptChanges on a DataSet?
Jim
"Marina" wrote:
Yes - you called AcceptChanges. This changes the states of all the rows to unmodified. So when you go to update, it looks like there is nothing to update.
Why call AcceptChanges to change all the row states if you then want to update?
"Jim Reynolds" <Ji*********@di scussions.micro soft.com> wrote in message news:F0******** *************** ***********@mic rosoft.com... > Hi, > I am using a SqlCommandBuild er to update a Db table via an updated > DataSet > and SqlAdapter and it doesn't seem to be generating the activity > commands > from the Select command. Here is a snippet. > > sda = new SqlDataAdapter( ); > sda.SelectComma nd = new SqlCommand(sql, dbcon); > SqlCommandBuild er scb = new SqlCommandBuild er(sda); > > DataSet ds = new DataSet(); > sda.Fill(ds,pag eName); > > DataRow dr = ds.Tables[pageName].NewRow(); > > for(int x=0;x<14;x++) > { > dr[x] = newDataRow[x]; > } > ds.Tables[pageName].Rows.Add(dr); > ds.AcceptChange s(); > sda.Update(ds,p ageName); > > Nothing happens, no update and no exceptions. Any ideas please? > > Jim This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Nick |
last post by:
Hi,
The SqlCommandBuilder class seems to be able to remember
the primary key of a row such that even if I change that
key's value, it is still able to update only that row.
So I would like to know how can I update a row even when
the primary key is changed by the user? From the row's
columns' information the original information seems to be
lost so that I can specify to update only the row with
the original primary key.
|
by: Hank1234 |
last post by:
Can I use one Data Adapter and one Command Builder to update amny tables?
Currently in my data adapter I query two tables and fill them into two tables
in a data set. When I make a change to a record in the second table and call
the update method of the data adapter the command builders update command
text is for the first table. Can the command builder handle two tables?
Code example:
Dim oCOnn As New SqlConnection("Data Source=.;" &...
|
by: Rico Alexander |
last post by:
is there a way to retrieve the value of an autoincrement column inserted in
the database?
|
by: microsoft.private.windows.netserver.setup |
last post by:
I have a very strange thing occurring in the program. I have a dataset
retrieved from a stored procedure that just select * from a table. I then
try to use the SQlCommandBuilder on the dataset, and fails. I try the same
select statement directly and not using a stored procedure and use
SQLCommandBuilder, the program works. This is a ASP.net page, and I am
stumped. I would like to use the stored procedure rather than controlling
it in...
|
by: DG |
last post by:
I use this code:
_adapter = new SqlDataAdapter(selectString, _conn);
_adapter.SelectCommand = new SqlCommand(selectString, _conn);
_adapter.SelectCommand.Transaction = _trans;
_builder = new SqlCommandBuilder(_adapter);
_adapter.Update(dt);
i get exception:
Execute requires the command to have a transaction object when the
| |
by: Tony Johansson |
last post by:
Hello!
This small program below works but I have some questions about it.
Below I have a piece of code that update a specific row in the northwind
database.
The class SqlCommandBuilder is used for creating a suitable update,insert or
delete sql command that
match thisAdapter.
|
by: Tony Johansson |
last post by:
Hello!
When I use this SqlCommandBuilder will there be created sql command for all
three sql statement(update,insert and delete)
//Tony
|
by: raulbolanos |
last post by:
Hi Pr0's,
I have a problem trying to implement the same example from this link:
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommandbuilder.aspx
But instead of Sql I use MySql. When I fill the DataSet with the data from the DB I dont have any trouble I can even fill also a DataGridViewer and display the data in my form.
The problem is when I want to use the GetUpdateCommand. I get an exception error like "Dynamic...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |