Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8037075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:48:59+00:00 2026-06-05T02:48:59+00:00

I have the following code: DataSet dataSet = new DataSet(); bool result; using (SqlConnection

  • 0

I have the following code:

DataSet dataSet = new DataSet();
                bool result;
                using (SqlConnection connection = new SqlConnection(command.Connection.ConnectionString))
            {
            connection.Open();                             

            SqlDataAdapter adapter = new SqlDataAdapter(command);
            SqlCommandBuilder builder = new SqlCommandBuilder(adapter);

            adapter.RowUpdated += OnRowUpdated;
            adapter.RowUpdating += AdapterOnRowUpdating;


            adapter.Fill(dataSet);

            // Code to modify data in the DataSet here.
            // Without the SqlCommandBuilder, this line would fail.
            adapter.UpdateCommand = builder.GetUpdateCommand();

            int i = adapter.Update(dataSet);
            result = i > 0;
        }
        return result;

this code is suppose to take my SqlCommand object and submit it to the update method of the SqlDataAdapter. The SqlCommand could be an INSERT, UPDATE or DELETE which is executed using the adapter.Update() method.

The command executes successfully but the adapter.Update() method returns 0 rows. I have checked the database and I can see that it was successful. The RowUpdated and RowsUpdating events are also not firing. I’m not sure whats going on. Please help.

Thank you in advance.

EDIT:

 public void OnRowUpdated(object sender, SqlRowUpdatedEventArgs sqlRowUpdatedEventArgs)
        {
            switch (sqlRowUpdatedEventArgs.StatementType)
            {
                case StatementType.Insert:
                case StatementType.Update:
                case StatementType.Delete:
                case StatementType.Batch:
                    if (sqlRowUpdatedEventArgs.Status != UpdateStatus.ErrorsOccurred)
                        SqlReporting.LogSqlCommand(sqlRowUpdatedEventArgs.Command);
                    break;
            }
        }

EDIT:
Im using the following query to Insert:

INSERT INTO Users
                         (Username, Firstname, Lastname, RoleId, ReceiveRoleAlerts, StatusId, Password, Fingerprint, AuthenticityCheck, CreatedByUserId, CreationDate, ModifiedByUserId, 
                         ModificationDate)
SELECT        @Username AS Expr1, @Firstname AS Expr2, @Lastname AS Expr3, @RoleId AS Expr4, @ReceiveRoleAlerts AS Expr5, @StatusId AS Expr6, @Password AS Expr7, 
                         @Fingerprint AS Expr8, @AuthenticityCheck AS Expr9, @CreatedByUserId AS Expr10, @CreationDate AS Expr11, @ModifiedByUserId AS Expr12, 
                         @ModificationDate AS Expr13
WHERE        (NOT EXISTS
                             (SELECT        Username, Firstname, Lastname, RoleId, ReceiveRoleAlerts, StatusId, Password, Fingerprint, AuthenticityCheck, CreatedByUserId, CreationDate, 
                                                         ModifiedByUserId, ModificationDate
                               FROM            Users AS Users_1
                               WHERE        (Username = @Username)));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T02:49:01+00:00Added an answer on June 5, 2026 at 2:49 am

    Use

    adapter.RowUpdating += new SqlRowUpdatingEventHandler(AdapterOnRowUpdating); 
    adapter.RowUpdated += new SqlRowUpdatedEventHandler(OnRowUpdated);
    

    instead of

    adapter.RowUpdated += OnRowUpdated;
    adapter.RowUpdating += AdapterOnRowUpdating;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code mycon=new SqlConnection(); mycon.ConnectionString='Provider =Microsoft.ACE.OLEDB.12.0';Data Source='G:\\Abbriviations\\Abbriviations\\App_Data\\abbreviations.accdb'; myds=new DataSet(); mytable =
I have the following code public class BaseController : Controller { SqlConnection con; DataSet
I have the following C# code: public string TargetDate() { SqlConnection con = new
I have the following code for using an access database OleDbConnection con = new
i have the following code to fill two comboboxes using one dataset: Private Sub
I have following code if (rs != null) { out.println(result set has got something);
I have following code for opening all files: int ret= open(zFile, flags, mode); posix_fadvise
Suppose that I have the following code: private void UpdateDB(QuoteDataSet dataSet, Strint tableName) {
The following code: DataSet ds = new DataSet; ds.ReadXml(c:\output\ + nome); GridView1.DataSource = ds;
I have the following code to retrieve a dataset from a database. I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.