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 427419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:34:33+00:00 2026-05-12T19:34:33+00:00

Here is the code, any ideas why I get this error? private SQLiteDataAdapter DA_Webfiles;

  • 0

Here is the code, any ideas why I get this error?

private SQLiteDataAdapter DA_Webfiles;
// Setup connection, fill dataset etc

DataTable dt = this.dataSet.Tables["WEBFILES"];
DataRow newRow = dt.NewRow();
newRow["PATH"] = _url;
dt.Rows.Add(newRow);
this.DA_Webfiles.Update(this.dataSet, "WEBFILES");
// Works to Here

newRow["CONTENT_TYPE"] = "Test Content Type";
this.DA_Webfiles.Update(this.dataSet, "WEBFILES");
// Get ERROR here - Concurrency violation: the UpdateCommand affected 0 of the expected 1 records
  • 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-05-12T19:34:34+00:00Added an answer on May 12, 2026 at 7:34 pm

    you need: dataAdapter.InsertCommand.UpdatedRowSource = UpdateRowSource.FirstReturnedRecord;

    got code clue here: Retrieving Identity or Autonumber Values (ADO.NET)

    the table:

    CREATE TABLE [emp] (
    [emp_id] INTEGER  NOT NULL PRIMARY KEY AUTOINCREMENT,
    [emp_firstname] VARCHAR(100) NOT NULL,
    [emp_lastname] varchar(100) not null
    )
    

    the code:

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
    
    
            var c = Connect();
    
            var da = new SQLiteDataAdapter("select emp_id, emp_firstname, emp_lastname from emp where 1 = 0", c);
    
    
    
            var b = new SQLiteCommandBuilder(da);
    
            da.InsertCommand = new SQLiteCommand(
                @"insert into emp(emp_firstname, emp_lastname ) values(:_emp_firstname, :_emp_lastname);
                select emp_id /* include rowversion field here if you need */ from emp where emp_id = last_insert_rowid();", c);
            da.InsertCommand.Parameters.Add("_emp_firstname", DbType.String, 0, "emp_firstname");
            da.InsertCommand.Parameters.Add("_emp_lastname", DbType.String, 0, "emp_lastname");
            da.InsertCommand.UpdatedRowSource = UpdateRowSource.FirstReturnedRecord;
    
            da.UpdateCommand = b.GetUpdateCommand();
            da.DeleteCommand = b.GetDeleteCommand();
    
    
            var dt = new DataTable();
            da.Fill(dt);
    
            var nr = dt.NewRow();
            nr["emp_firstname"] = "john";
            nr["emp_lastname"] = "lennon";
    
            dt.Rows.Add(nr);
    
            da.Update(dt);
    
            dt.AcceptChanges();
    
            nr["emp_lastname"] = "valjean";
            da.Update(dt);
    
        }
    
        SQLiteConnection Connect()
        {
            return new SQLiteConnection(@"Data Source=../../test.s3db;Version=3;");
        }
    }
    

    the code above works on multi-insert too. proof-of-concept code:

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
    
    
            var c = Connect();
    
            var da = new SQLiteDataAdapter("select emp_id, emp_firstname, emp_lastname from emp where 1 = 0", c);
    
    
    
            var b = new SQLiteCommandBuilder(da);
    
            da.InsertCommand = new SQLiteCommand(
                @"insert into emp(emp_firstname, emp_lastname ) values(:_emp_firstname, :_emp_lastname);
                select emp_id /* include rowversion field here if you need */ from emp where emp_id = last_insert_rowid();", c);
            da.InsertCommand.Parameters.Add("_emp_firstname", DbType.String, 0, "emp_firstname");
            da.InsertCommand.Parameters.Add("_emp_lastname", DbType.String, 0, "emp_lastname");
            da.InsertCommand.UpdatedRowSource = UpdateRowSource.FirstReturnedRecord;
    
            da.UpdateCommand = b.GetUpdateCommand();
            da.DeleteCommand = b.GetDeleteCommand();
    
    
            var dt = new DataTable();
            da.Fill(dt);
    
            var nr = dt.NewRow();
            nr["emp_firstname"] = "john";
            nr["emp_lastname"] = "lennon";
    
    
            var nrx = dt.NewRow();
            nrx["emp_firstname"] = "paul";
            nrx["emp_lastname"] = "mccartney";
    
    
            dt.Rows.Add(nr);
            dt.Rows.Add(nrx);
    
            da.Update(dt);
    
            dt.AcceptChanges();
    
    
            nrx["emp_lastname"] = "simon";
            da.Update(dt);
    
            nr["emp_lastname"] = "valjean";
            da.Update(dt);
    
        }
    
        SQLiteConnection Connect()
        {
            return new SQLiteConnection(@"Data Source=../../test.s3db;Version=3;");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

See here: http://code.google.com/p/ie7-js/ Does anyone have any experience or remarks about this javascript? Is
I have this code here, which is intended to allow any type of arguments:
Ok the error is showing up somewhere in this here code if($error==false) { $query
Here is my code... basically it finds any page-NUMBER- within a variable and then
Here is my code Socket sck = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); sck.Bind(new IPEndPoint(IPAddress.Any, 0));
I have the following code, which compiles but doesn't bring back any data. Here
I am trying to serialize some Linq objects using this code. private byte[] GetSerializedObj(object
For some reason I can't get open() to open a file. Here's my code.
Here is code from MSDN . I don't understand why the work isn't just
Here a code to demonstrate an annoying problem: class A { public: A(): m_b(1),

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.