views:

10

answers:

0

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"]);

thanks!