473,378 Members | 1,622 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,378 software developers and data experts.

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(cnStr))
{
SqlCommand updCmd = new SqlCommand
("sp_web_edit_manager_update", cn);

SqlDataAdapter adpt = new SqlDataAdapter(updCmd);

updCmd.UpdatedRowSource = UpdateRowSource.None;
updCmd.Parameters.Add("@entity", SqlDbType.VarChar,10,
dtOnlyChanges.Columns[0].ColumnName);
updCmd.Parameters.Add("@edit_id", SqlDbType.Int, 4,
dtOnlyChanges.Columns[1].ColumnName);
updCmd.Parameters.Add("@edit_override", SqlDbType.VarChar, 1,
dtOnlyChanges.Columns[2].ToString());
updCmd.Parameters.Add("@biller_cd", SqlDbType.VarChar, 20,
dtOnlyChanges.Columns[3].ToString());
updCmd.Parameters.Add("@include_in_stats", SqlDbType.VarChar,
1, dtOnlyChanges.Columns[4].ToString());

adpt.UpdateCommand = updCmd;

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

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

}

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

-- bruce (sqlwork.com)

"andy6" <u9025@uwe> wrote in message news:61cf9e8450e76@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(cnStr))
{
SqlCommand updCmd = new SqlCommand
("sp_web_edit_manager_update", cn);

SqlDataAdapter adpt = new SqlDataAdapter(updCmd);

updCmd.UpdatedRowSource = UpdateRowSource.None;
updCmd.Parameters.Add("@entity", SqlDbType.VarChar,10,
dtOnlyChanges.Columns[0].ColumnName);
updCmd.Parameters.Add("@edit_id", SqlDbType.Int, 4,
dtOnlyChanges.Columns[1].ColumnName);
updCmd.Parameters.Add("@edit_override", SqlDbType.VarChar,
1,
dtOnlyChanges.Columns[2].ToString());
updCmd.Parameters.Add("@biller_cd", SqlDbType.VarChar, 20,
dtOnlyChanges.Columns[3].ToString());
updCmd.Parameters.Add("@include_in_stats",
SqlDbType.VarChar,
1, dtOnlyChanges.Columns[4].ToString());

adpt.UpdateCommand = updCmd;

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

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

}

--
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(DBConnectionString))
{
using (SqlCommand updCmd = new SqlCommand
("sp_web_edit_manager_update", cn))
{
SqlDataAdapter adpt = new SqlDataAdapter(updCmd);
updCmd.CommandType = CommandType.StoredProcedure;
updCmd.CommandTimeout = Convert.ToInt32
(ConfigurationSettings.AppSettings["dbCommandTimeout"]);

updCmd.UpdatedRowSource = UpdateRowSource.None;
updCmd.Parameters.Add("@entity", SqlDbType.VarChar, 10,
dtOnlyChanges.Columns[0].ColumnName);
updCmd.Parameters.Add("@edit_id", SqlDbType.Int, 4,
dtOnlyChanges.Columns[1].ColumnName);
updCmd.Parameters.Add("@edit_override", SqlDbType.VarChar,
1, dtOnlyChanges.Columns[2].ToString());
updCmd.Parameters.Add("@biller_cd", SqlDbType.VarChar, 20,
dtOnlyChanges.Columns[3].ToString());
updCmd.Parameters.Add("@include_in_stats", SqlDbType.
VarChar, 1, dtOnlyChanges.Columns[4].ToString());

adpt.UpdateCommand = updCmd;

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

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

cn.Open();

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

--
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
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...
0
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
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...
1
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...
1
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-...
0
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...
2
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...
0
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...
1
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.