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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:48:46+00:00 2026-05-21T22:48:46+00:00

I know this is a silly question and I feel so stupid , but

  • 0

I know this is a silly question and I feel so stupid, but I can’t find the right (the easy) way to accomplish my task.
I have an Access database imported in Visual Studio 2010 for a C# project: VS creates for me (thanks!!) strongly-typed dataset about my db. Well done.
Then, in my app, I create a new instance of this dataset CDS ds = new CDS(); and add records in its tables. Finally I do ds.AcceptChanges(); but nothing happens on db.
OK, I googled araound and think (realize?!?) I gotta open a db connection, create a DataAdapter and fill my dataset with this:

CDS ds = new CDS();
OleDbConnection conn = new OleDbConnection(path_to_db);
conn.Open();
OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM mytable", conn);
da.Fill(ds.Editori); //Editori is a TableTable created automatically
// Insert rows in dataset
if (ds.HasChanges()) ds.AcceptChanges();
int ret = da.Update(ds.Editori);
Debug.Print("Update() returns: {0}", ret);
conn.Close();

but ret=0 and nothing happens on database, while in DS.Editori I have 106 rows!!

To complete my desperation: table mytable has an auto increment field as primary key; when I load ds with da, this field is correct for every record, but when I insert rows on ds, records have -1, -2, -3, etc… Why?

Can someone tells me the right way to work with strongly-typed datasets?
I gonna study, read books, I promise, but now I’m late for this job…
Thanks

UPDATE:
As suggested from Dev-Express I created the insert command, but the result is the same: when I update da, nothing happens on db.

OleDbCommand cmd = new OleDbCommand(
    "INSERT INTO Editori (ID,Editore) VALUES(?,?)", conn);
cmd.Parameters.Add("@ID", OleDbType.Integer);
cmd.Parameters.Add("@Editore", OleDbType.VarChar, 255, "Editore");
da.InsertCommand = cmd;
int ret = da.Update(ds.Editori);
Debug.Print("Update() returns: {0}", ret);
conn.Close();

ANOTHER UPDATE:
I solved problem with primary keys: in generated class I manually had to change all of these lines:

this.columnID.AutoIncrementSeed = 1; // It was -1
this.columnID.AutoIncrementStep = 1; // It was -1
  • 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-21T22:48:47+00:00Added an answer on May 21, 2026 at 10:48 pm

    You should also specify the UpdateCommand of the OleDBDataAdapter and then execute it by calling the da.Update method. There is an example of how this can be done in the MSDN:

    OleDbDataAdapter.OleDbDataAdapter(String, OleDbConnection) Constructor

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this is a silly question but i can't find out how to
I know the question sounds silly, but consider this: I have an array of
I know this might sound a silly question, but I did not find in
I know this may be a silly question for experienced coders. But I have
I know this may be a silly question. but stil i have a confusion.
I am a newbie on HTML5. I know this is a silly question but
Guys I know this question is silly but just to make sure: Having in
This may be a silly question I don't know. Is there a way to
Ok so this maybe a simple/silly question but I don't know so here goes:
Now this may seem like a silly question, but I need to know how

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.