473,583 Members | 3,114 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Actually, ado.net 2.0 help needed - batch update failing

I am using the following code and SQL Profiler shows no activity when I step
through the .update line. Do you see a syntax error?
Thanks!

using (SqlConnection cn = new SqlConnection(c nStr))
{
SqlCommand updCmd = new SqlCommand
("sp_web_edit_m anager_update", cn);

SqlDataAdapter adpt = new SqlDataAdapter( updCmd);

updCmd.UpdatedR owSource = UpdateRowSource .None;
updCmd.Paramete rs.Add("@entity ", SqlDbType.VarCh ar,10,
dtOnlyChanges.C olumns[0].ColumnName);
updCmd.Paramete rs.Add("@edit_i d", SqlDbType.Int, 4,
dtOnlyChanges.C olumns[1].ColumnName);
updCmd.Paramete rs.Add("@edit_o verride", SqlDbType.VarCh ar, 1,
dtOnlyChanges.C olumns[2].ToString());
updCmd.Paramete rs.Add("@biller _cd", SqlDbType.VarCh ar, 20,
dtOnlyChanges.C olumns[3].ToString());
updCmd.Paramete rs.Add("@includ e_in_stats", SqlDbType.VarCh ar,
1, dtOnlyChanges.C olumns[4].ToString());

adpt.UpdateComm and = updCmd;

// Set the Batch Size. 0 means all; default is 1.
adpt.UpdateBatc hSize = 10;

// Send the new rows and the changed rows to the database
adpt.Update(dtO nlyChanges);

}

--
Message posted via http://www.dotnetmonster.com
Jun 15 '06 #1
2 1653
probably no changed (rowstate == modified) rows in the dataset to update.

-- bruce (sqlwork.com)

"andy6" <u9025@uwe> wrote in message news:61cf9e8450 e76@uwe...
I am using the following code and SQL Profiler shows no activity when I
step
through the .update line. Do you see a syntax error?
Thanks!

using (SqlConnection cn = new SqlConnection(c nStr))
{
SqlCommand updCmd = new SqlCommand
("sp_web_edit_m anager_update", cn);

SqlDataAdapter adpt = new SqlDataAdapter( updCmd);

updCmd.UpdatedR owSource = UpdateRowSource .None;
updCmd.Paramete rs.Add("@entity ", SqlDbType.VarCh ar,10,
dtOnlyChanges.C olumns[0].ColumnName);
updCmd.Paramete rs.Add("@edit_i d", SqlDbType.Int, 4,
dtOnlyChanges.C olumns[1].ColumnName);
updCmd.Paramete rs.Add("@edit_o verride", SqlDbType.VarCh ar,
1,
dtOnlyChanges.C olumns[2].ToString());
updCmd.Paramete rs.Add("@biller _cd", SqlDbType.VarCh ar, 20,
dtOnlyChanges.C olumns[3].ToString());
updCmd.Paramete rs.Add("@includ e_in_stats",
SqlDbType.VarCh ar,
1, dtOnlyChanges.C olumns[4].ToString());

adpt.UpdateComm and = updCmd;

// Set the Batch Size. 0 means all; default is 1.
adpt.UpdateBatc hSize = 10;

// Send the new rows and the changed rows to the database
adpt.Update(dtO nlyChanges);

}

--
Message posted via http://www.dotnetmonster.com

Jun 15 '06 #2
Good catch! Thank you.

I ended up with this code.

using (SqlConnection cn = new SqlConnection(D BConnectionStri ng))
{
using (SqlCommand updCmd = new SqlCommand
("sp_web_edit_m anager_update", cn))
{
SqlDataAdapter adpt = new SqlDataAdapter( updCmd);
updCmd.CommandT ype = CommandType.Sto redProcedure;
updCmd.CommandT imeout = Convert.ToInt32
(ConfigurationS ettings.AppSett ings["dbCommandTimeo ut"]);

updCmd.UpdatedR owSource = UpdateRowSource .None;
updCmd.Paramete rs.Add("@entity ", SqlDbType.VarCh ar, 10,
dtOnlyChanges.C olumns[0].ColumnName);
updCmd.Paramete rs.Add("@edit_i d", SqlDbType.Int, 4,
dtOnlyChanges.C olumns[1].ColumnName);
updCmd.Paramete rs.Add("@edit_o verride", SqlDbType.VarCh ar,
1, dtOnlyChanges.C olumns[2].ToString());
updCmd.Paramete rs.Add("@biller _cd", SqlDbType.VarCh ar, 20,
dtOnlyChanges.C olumns[3].ToString());
updCmd.Paramete rs.Add("@includ e_in_stats", SqlDbType.
VarChar, 1, dtOnlyChanges.C olumns[4].ToString());

adpt.UpdateComm and = updCmd;

// Set the Batch Size. 0 means all; default is 1.
adpt.UpdateBatc hSize = 0;

foreach(DataRow b in dtOnlyChanges.R ows)
{
b.SetModified() ;
}

cn.Open();

// send the changed rows("modified" ) to the database
adpt.Update(dtO nlyChanges);
}
}

--
Message posted via http://www.dotnetmonster.com
Jun 15 '06 #3

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

Similar topics

2
6555
by: Paul Reddin | last post by:
Hi, (V8.1 Fp2) Our application uses JDBC batch to execute mutiple insert statements and we saw a strange thing this morning. There were 4 SQL Insert statements in the batch, and we know the 2nd would have violated a Unique Constraint and failed, but the SQL error returned was related to the 3rd statement (which had a FK dependent on the...
0
1910
by: jayson_13 | last post by:
Hi, I would like to execute a batch update (mysql) with C#. How do I do that? For example, OdbcCommand cmd = New OdbcCommand(); Cmd.Connection = Conn;
6
11208
by: Charles Neitzel | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running programs and executing registry entries. The majority of my buttons work however, I have come upon a problem. I need a few of the buttons to run DOS batch...
1
3166
by: Charles | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running programs and executing registry entries. The majority of my buttons work however, I have come upon a problem. I need a few of the buttons to run DOS...
1
2497
by: John Thompson | last post by:
We're sooo close. When we load the page to upload the image, all of the prms go through except the binary image data. Using SQL server with the data type set to "image". Please help! Thanks- John
0
1326
by: c3q8 | last post by:
I have a batch system where the user enter suppliers invoices to a batch table (SupVchBat) then selectively update certain invoice to outstanding invoice table (SupVch) and updated suppliers (Supplier.sup_mtdpur) current balance and warehouse (warehouse.WHS_ MTD_SALE). Such is done currently in the front end using VB, but the process is very...
2
2622
by: Hexman | last post by:
Hello All, Well I'm stumped once more. Need some help. Writing a simple select and update program using VB.Net 2005 and an Access DB. I'm using parameters in my update statement and when trying to update a record, I get a "No value given for one or more parameters." error message. I use a Select with parameters and an Update with...
0
1189
by: Steve | last post by:
ASP.net 2.0 SQL 2005 I need to insert/delete multiple records from a database. Error checking and exceptions are not a problem, the data being added/deleted are simple integer IDs. The number of records being affected would typically be in the 1 to 50 range.
1
3575
by: bravo | last post by:
hi using mysql 4.1 i wish to update records using batch update but for a batch of 100, records and table having only 5000 records execution time is approx 2.4 sec i want to know whether this time is fine or i can further reduce it with some performance tunning ... the table which i am using is having 19 columns the update is on a single column...
0
7896
marktang
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...
0
8184
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
6581
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5701
isladogs
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...
0
5375
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3820
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...
0
3845
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1434
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1158
bsmnconsultancy
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...

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.