Jump to content
Xtreme .Net Talk

ChoKamir

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by ChoKamir

  1. Thanks for your answer, although i was hoping for an easier method. Because how i interpreted your answer is: In the RowUpdated event i execute a command selecting the newly inserted row. I loop through the columns in the datareader and set them to the row by e.Row.ItemArray.SetValue(reader,i). Although what ever i trie this function SetValue returns: Expression has been evaluated and has no value. Also when i user e.Row.ItemArray[2] = 0. No matter what i try it doesn't store the values. What am i doing wrong now? Thanks
  2. Hey, First of all i work with an access database. In my program i made an DataAdapter with retrieves rows from the database from two tables(through an inner join). Because the dataset linked to this DataAdapter is represented in a datagridview i also wrote insert, delete and update commands. The way i solved the insert in two tables is with an transaction. In the RowUpdating event of the DataAdapter i create an transaction and manually insert the row in one of the tables. The insertcommand of the dataadapter will handle the insert in the other table. In the RowUpdated event of the dataadapter i commit the transaction. This works all fine, except for the fact that some values in the datagrid are left empty because then the default values will be inserted and there is a column with a expression (calculating the product of two columns of a row). Now the default values won't appear nor will the column with the expression show a value. The reason for this is that the inserted data into the database is not returned to the dataset. So how can i make sure that the actual data of the inserted row in the database is reflected to the dataset? Thanks for helping ChoKamir
  3. Thanks for thinking with me guys. I tried but doesn't help. It gets in a neverending loop when the action commit is triggered. If i filter on that the error still comes up. I added some debuging lines to track the whole process, maybe it helps. This is the sourcecode of the events to track what is happening. void dataAdapter_RowUpdated(object sender, OleDbRowUpdatedEventArgs e) { System.Diagnostics.Debug.Print("### UPDATED("+ e.RecordsAffected + ") ###: " + e.Command.CommandText + " (" + e.Command.Parameters[0].Value + ")"); } void dataAdapter_RowUpdating(object sender, OleDbRowUpdatingEventArgs e) { System.Diagnostics.Debug.Print("### UPDATING ###: " + e.Command.CommandText + " (" + e.Command.Parameters[0].Value + ")"); } /************************************ * Makes sure that the database is updated after a row is deleted ***********************************/ void DatabaseTable_RowDeleted(object sender, DataRowChangeEventArgs e) { System.Diagnostics.Debug.Print("(" + this.table + ") Row Deleted: " + e.Action.ToString()); try { dataAdapter.Update(this); this.AcceptChanges(); } catch (OleDbException ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } catch (DBConcurrencyException ex) { System.Diagnostics.Debug.Print("### ERROR ###: " + ex.Message); } } /************************************ * Makes sure that the database is updated after a row is changed ***********************************/ void DatabaseTable_RowChanged(object sender, DataRowChangeEventArgs e) { System.Diagnostics.Debug.Print("(" + this.table + ") Row Changed: " + e.Action.ToString()); //if (e.Action == DataRowAction.Add || e.Action == DataRowAction.Change) { //System.Diagnostics.Debug.Print("(" + this.table + ") Row Changed: " + e.Row.ItemArray[0].ToString() + "-" + e.Row.ItemArray[1].ToString()); try { dataAdapter.Update(this); if (e.Action != DataRowAction.Commit) this.AcceptChanges(); } catch (OleDbException ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } } } The debug output when the deletion is succesfull () Row Changed: Add ### UPDATING ###: INSERT INTO tbl_dagen (dag) VALUES (?) (sdfasd) () Row Changed: Commit ### UPDATED(1) ###: INSERT INTO tbl_dagen (dag) VALUES (?) (sdfasd) () Row Deleted: Delete ### UPDATING ###: DELETE FROM tbl_dagen WHERE id = ? (64) ### UPDATED(1) ###: DELETE FROM tbl_dagen WHERE id = ? (64) () Row Changed: Commit The output with the error () Row Changed: Add ### UPDATING ###: INSERT INTO tbl_dagen (dag) VALUES (?) (sdfa) () Row Changed: Commit ### UPDATED(1) ###: INSERT INTO tbl_dagen (dag) VALUES (?) (sdfa) () Row Deleted: Delete ### UPDATING ###: DELETE FROM tbl_dagen WHERE id = ? (66) ### UPDATED(0) ###: DELETE FROM tbl_dagen WHERE id = ? (66) A first chance exception of type 'System.Data.DBConcurrencyException' occurred in System.Data.dll ### ERROR ###: Concurrency violation: the DeleteCommand affected 0 of the expected 1 records. Thanks alot for helping, it really got me puzzled. I reckon it has something to do with how the ADO.NET functions in the background. Thanks, ChoKamir
  4. Hey Guys, I'm having a weird problem. I wrote some simple application in c# which shows the data of a acces database in a datagridview. On the RowChanged and RowDeleted events of the dataset i do a dataAdapter.update(dataset). It works all fine, i can add new rows, change and delete excisting rows. All no problem. The problem starts when i add a new row and then try to delete that newly added row. I know that it executes the insert statement and finishes it succesfully, so the row excists in the database aswell as in the datagridview. But when i then try to delete i get the DBConcurrencyException telling me: Concurrency violation: the DeleteCommand affected 0 of the expected 1 records. The weird thing is that when i first select another row and then return to the new row and delete it no problem. So my feeling is that it somehow didn't completly wrote the new row to the database but only to the memory or something like that. Is that possible? how can i check that? and how can i prevent it? This problem happens about 90% of the time. I hope somebody can help out. Greetings ChoKamir
  5. Hello I'm new to Visual C++ .NET i've been looking around a bit on the net for good books to start off with. But also not spending half the book on the basics. I'm a fairly good VB6 programmer so basic programming stuff i know. I don't need 500 pages on all the syntacs. Just how to use the C++ .NET envirement the syntact etc in short and goin into depth on advanced stuff like XML, Database, Internet etc. I found a few books but all the reviews had a big discussion about that the books did go to much into MFC and not too much into managed code. So here another question for you vokes. What is meant by MFC/COM and Managed code. As far as i understood from those reviews MFC/COM is the base for all or something. Anyway some explanation would be apreciated very much and any comments on good books are always welcome. ChoKamir
  6. Alright thanks a lot optikal
  7. Alright thanks m8 Another question i wasn't able to find on the microsoft website. How many CD's does .NET 2003 contain and does it use the MSDN library as help file. If so i guess that is a different MSDN library than the one of VS 6. ChoKamir
  8. Hello As you can see i'm new here, due to the fact that i was wondering what would be the best solution. I'm now a VB5 programmer and wanna start getting skills in C++. Now i my question what do all of you suggest, that use Visual C++6 or .Net. And pls tell me what you like .net(i think this will be your opinion due the the fact this is a .net forum). And if you have any links/ articles discussing the pro's and against pls tell me. ChOkamir
×
×
  • Create New...