473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

SqlCommandBuilder

Hi,
I am using a SqlCommandBuilder 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.SelectCommand = new SqlCommand(sql,dbcon);
SqlCommandBuilder scb = new SqlCommandBuilder(sda);

DataSet ds = new DataSet();
sda.Fill(ds,pageName);

DataRow dr = ds.Tables[pageName].NewRow();

for(int x=0;x<14;x++)
{
dr[x] = newDataRow[x];
}
ds.Tables[pageName].Rows.Add(dr);
ds.AcceptChanges();
sda.Update(ds,pageName);

Nothing happens, no update and no exceptions. Any ideas please?

Jim
Nov 19 '05 #1
4 2123
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*********@discussions.microsoft.com> wrote in message
news:F0**********************************@microsof t.com...
Hi,
I am using a SqlCommandBuilder 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.SelectCommand = new SqlCommand(sql,dbcon);
SqlCommandBuilder scb = new SqlCommandBuilder(sda);

DataSet ds = new DataSet();
sda.Fill(ds,pageName);

DataRow dr = ds.Tables[pageName].NewRow();

for(int x=0;x<14;x++)
{
dr[x] = newDataRow[x];
}
ds.Tables[pageName].Rows.Add(dr);
ds.AcceptChanges();
sda.Update(ds,pageName);

Nothing happens, no update and no exceptions. Any ideas please?

Jim

Nov 19 '05 #2
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*********@discussions.microsoft.com> wrote in message
news:F0**********************************@microsof t.com...
Hi,
I am using a SqlCommandBuilder 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.SelectCommand = new SqlCommand(sql,dbcon);
SqlCommandBuilder scb = new SqlCommandBuilder(sda);

DataSet ds = new DataSet();
sda.Fill(ds,pageName);

DataRow dr = ds.Tables[pageName].NewRow();

for(int x=0;x<14;x++)
{
dr[x] = newDataRow[x];
}
ds.Tables[pageName].Rows.Add(dr);
ds.AcceptChanges();
sda.Update(ds,pageName);

Nothing happens, no update and no exceptions. Any ideas please?

Jim


Nov 19 '05 #3
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*********@discussions.microsoft.com> wrote in message
news:6C**********************************@microsof t.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*********@discussions.microsoft.com> wrote in message
news:F0**********************************@microsof t.com...
> Hi,
> I am using a SqlCommandBuilder 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.SelectCommand = new SqlCommand(sql,dbcon);
> SqlCommandBuilder scb = new SqlCommandBuilder(sda);
>
> DataSet ds = new DataSet();
> sda.Fill(ds,pageName);
>
> DataRow dr = ds.Tables[pageName].NewRow();
>
> for(int x=0;x<14;x++)
> {
> dr[x] = newDataRow[x];
> }
> ds.Tables[pageName].Rows.Add(dr);
> ds.AcceptChanges();
> sda.Update(ds,pageName);
>
> Nothing happens, no update and no exceptions. Any ideas please?
>
> Jim


Nov 19 '05 #4
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*********@discussions.microsoft.com> wrote in message
news:6C**********************************@microsof t.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*********@discussions.microsoft.com> wrote in message
news:F0**********************************@microsof t.com...
> Hi,
> I am using a SqlCommandBuilder 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.SelectCommand = new SqlCommand(sql,dbcon);
> SqlCommandBuilder scb = new SqlCommandBuilder(sda);
>
> DataSet ds = new DataSet();
> sda.Fill(ds,pageName);
>
> DataRow dr = ds.Tables[pageName].NewRow();
>
> for(int x=0;x<14;x++)
> {
> dr[x] = newDataRow[x];
> }
> ds.Tables[pageName].Rows.Add(dr);
> ds.AcceptChanges();
> sda.Update(ds,pageName);
>
> Nothing happens, no update and no exceptions. Any ideas please?
>
> Jim


Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
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...
10
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...
1
by: Rico Alexander | last post by:
is there a way to retrieve the value of an autoincrement column inserted in the database?
5
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,...
0
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...
0
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...
1
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
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.