Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2715
How to save new records inserted in a ultragrid's child band?
posted

hi! the following snippet loads the data from three tables in two datasets and adds a relation between them : - users (user_id, name) - roles (role_id, role_name) - user_roles(user_id, role_id); into a Infragistics ultragrid. The data is siplayed in the grid, offering the posibility to add new rows. but here come the problem...how should i build the data adapter's insert command in order to insert my newky added row into the user_roles table ?

_cmd = new OracleCommand("select * from um_users", _conn);
            _odaUsers
= new OracleDataAdapter();
            _usersDataSet
= new DataSet("um_users");
            _odaUsers
.SelectCommand = _cmd;
            _odaUsers
.Fill(_usersDataSet, "um_users");


            _cmd
= new OracleCommand("select u.user_id,
r.role_id, r.role_name, r.descr "
+
                                   
"from um_users u " +
                                     
"inner join um_user_roles
ur on u.user_id = ur.user_id "
+
                                     
"inner join um_roles r
on ur.role_id = r.role_id "
, _conn);
            _odaUsers
.SelectCommand = _cmd;
           
OracleCommand _icmd = new OracleCommand("insert
into um_users_roles(@uid,@rid) values(?,?)"
, _conn);
            _icmd
.Parameters.Add("@uid",
Oracle
.DataAccess.Client.OracleDbType.Int32, 3, "USER_ID");
            _icmd
.Parameters.Add("@rid",
Oracle
.DataAccess.Client.OracleDbType.Int32, 3, "ROLE_ID");
            _odaUsers
.InsertCommand = _icmd;
            _odaUsers
.Fill(_usersDataSet, "um_users_roles");

            _usersDataSet
.Relations.Add("users_uur",
_usersDataSet
.Tables[0].Columns["USER_ID"],
_usersDataSet
.Tables[1].Columns["user_id"]);
Parents
No Data
Reply
  • 469350
    Offline posted

    Hi,

    This is a bit outside my area of expertise, since the grid does not get involved in the back end, it only deals with the local data source. I recommend checking Microsoft's documentation on the DataAdapter.

    Or, you might want to post your question in a more general DotNet programming or data binding forum, since your question isn't really related to the WinGrid.

Children
No Data