Below is the pseudo code:
SqlCeResultSet myResultSet = cmd.ExecuteResultSet(Options...etc); bool found = myResultSet.Seek(); if found { //do an Update myResultSet.Read() //make current //At this point we have a cursor positioned at a row to be edited myResultSet.SetString(1, "value for col 1"); myResultSet.SetString(2, "value for col 2"); //... etc... myResultSet.SetString(100, "value for col 100"); //i want to replace above with: CommonMethodToFillRowData(someRow) //finally update myResultSet.Update(); } else { //do an insert SqlCeUpdatableRecord myRec = myResultSet.CreateRecord(); //set primaryKey myRec.SetInt32(0, pkValue); //At this point we have a cursor positioned at a row to be edited myRec.SetString(1, "value for col 1"); myRec.SetString(2, "value for col 2"); //... etc... myRec.SetString(100, "value for col 100"); //i want to replace above with: CommonMethodToFillRowData(someRow) //finally insert myResultSet.Insert(myRec); }
From the above, if I have 100 columns to prepare, it needs to be repeated twice; What I want is CommonMethodToFillRowData (); But what type of parameter am I using for such a method?
CommonMethodToFillRowData(SqlCeResultSet or SqlCeUpdatableRecord ? parmRow) { parmRow.SetInt32(col1, value1) parmRow.SetString(col2, value2) ...etc. parmRow.SetString(100, "value for col 100"); }
Direct quoting from the MSDN doco in the SqlCeUpdatableRecord class: -> Represents a row of updated values from a data source. The SqlCeResultSet object contains one or more UpdatableRecords.
If so, why can’t I have direct access to one updated registry inside SqlCeResultSet, as soon as I put the cursor through Seek ()?
If it were possible, it would allow me to use:
CommonMethodToFillRowData(SqlCeUpdatableRecord parmRow) { //end of story }
joedotnot
source share