This explanation assumes knowledge of ASP.NET and provides a basic RedBack example. Stateful RBOs use a RedBack Session ID and they are stored on the RBO Server in a file that is garbage collected on a schedule you determine. The first time this object is opened it's handle and RedBack session id are stored off (in session, cookie, or hidden field). Subsequent opens then will get the previously stored handle and session id and use that to get the previously opened object complete with any data stored in it. (The Username and Password are blank.)
// The code to do this stateful open is complex (storing/getting previous handles, etc) // Please see the page source code in rbexamplesnetcsharp directory // After the complex gyrations, the command to open is the same, the following: ro.Open2(DatabaseName, RBHandle, Username, Password, RB_SessionId); To do the Read, we set the EmpId property and call the ReadData method and get back properties. //Set Id into Object Property myprop = (REDPAGESLib.RedProperty)ro.Property ("EmpId"); myprop.Value = (txtEmpId.Text).Trim(); //Call Method ro.CallMethod("ReadData"); //If RBO or SLRBO we would check some status property to see if Read Okay, // for uObject we can check new_item to see item existed myprop = (REDPAGESLib.RedProperty)ro.Property ("new_item"); NewItem = myprop.Value; if (NewItem == "1") { Mess.Text = "No Record found with Id = " + txtEmpId.Text; Mess.Text = Mess.Text + ". Try 1001 to 1024."; } myprop = (REDPAGESLib.RedProperty)ro.Property ("FirstName"); txtFirstName.Text = myprop.Value; myprop = (REDPAGESLib.RedProperty)ro.Property ("LastName"); txtLastName.Text = myprop.Value; To do the Write, we set the properties and call the WriteData method. In this simple example we are not concerning ourselves with concurrency control. //Set Properties myprop = (REDPAGESLib.RedProperty)ro.Property ("EmpId"); myprop.Value = (txtEmpId.Text).Trim(); myprop = (REDPAGESLib.RedProperty)ro.Property ("FirstName"); myprop.Value = ((txtFirstName.Text).Trim()); myprop = (REDPAGESLib.RedProperty)ro.Property ("LastName"); myprop.Value = ((txtLastName.Text).Trim()); //Call Method ro.CallMethod("WriteData"); //If RBO or SLRBO we would check some status property to see if Write Okay, // for uObject we could check lock_status to see if record was locked See the rbexamplesnetcsharp directory to review the page's entire source code. |