Nothing is happening in the database because you're running a SELECT query. What are you expecting to happen?
I used the command builder, I thought no need to write other command. If I am wrong please explain – sadboy Oct 8 '09 at 19:20 You're right, however, you must modify your dataset after (not before) it's filled with your adapter for the command builder to actually detect changes. – Steve Wortham Oct 8 '09 at 20:34.
Well unless you snipped a lot of code, you are not changing anything in the dataset per se. What are you trying to achieve? Here, you are selecting some data, filling the dataset with it, then putting back the unchanged dataset in the DB.
You should first change something in the dataset itself before calling adapter. Update(ds) Cheers, Florian.
The ds I get to this function is after change(I see it at runtime, when I debug) – sadboy Oct 8 '09 at 19:24.
You are selecting data via the SelectCommand. If you want to update data, you need to run the UpdateCommand.
I assume you didn't post the full source code, as it looks as though you're not modifying the dataset. However, I just tweaked your code a bit (see my comments). Hopefully this will help... string queryString = "SELECT * FROM tasks"; OleDbConnection connection = new OleDbConnection(cn.
ConnectionString); connection.Open(); // open connection first SqlCommand cmd = new SqlCommand(queryString, connection); OleDbDataAdapter adapter = new OleDbDataAdapter(cmd); // use the cmd above when instantiating the adapter OleDbCommandBuilder builder = new OleDbCommandBuilder(adapter); adapter. Fill(ds. Tables"Tasks"); // Modify your dataset here.
// Don't call AcceptChanges() as this will prevent the update from working. Adapter. Update(ds); connection.Close(); // Close connection before ending the function return ds; This should allow OleDbCommandBuilder to do its thing by automatically scripting the database updates.
The ds the function gets , already after changes. Perhaps I don't need to do fill? I change the ds in other layer and I send the changes ds to this function.
I looked at runtime and saw that the changes has been done in the ds – sadboy Oct 8 '09 at 19:23 You'd need to find a way to make the changes after the fill and before the update (where I've added that comment). That's the only way the DataAdapter, CommandBuilder, and Update magic will happen. – Steve Wortham Oct 8 '09 at 20:20 I think you don't need to do connection.open(), it will be handled by the data adapter automatically .. :) – Mahesh Velaga Oct 13 '09 at 11:20.
As far as I can see you've not actually changed any of the contents of the tasks table. When you call adapter. Fill you are populated the empty dataset with the records from the database.
You are then calling adapter. Update without changing any records within the dataset. The update command only performs changes when the dataset > datatable > datarows are edited and marked as dirty.
The ds is marked as dirty. When I do fill, does the ds is being populate again? The ds I get in this function is after changes – sadboy Oct 8 '09 at 19:26.
You are only specifying the select command. You also need to specify the insert command... i. E: DataAdapter.
InsertCommand = new OleDbCommand....
Saw only of sqlserver, and its not the same like access – sadboy Oct 8 '09 at 19:25 1 No, this isn't necessary when you use the command builder.But... there are some things about the command builder that can trip you up. See my answer for details. – Steve Wortham Oct 8 '09 at 20:27.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.