Link to home
Start Free TrialLog in
Avatar of jemigossaye
jemigossaye

asked on

Error while populating WebDatagrid: 'column' argument cannot be null.

hi all, it might be simple but i don't now what to do. I keep geting this error when i try to relate datasets. here is my code


            SqlConnection StrConn = new SqlConnection(ConfigurationSettings.AppSettings["StrConnectionString"]);
            SqlDataAdapter daUnassignedData = new SqlDataAdapter("select b.company, b.Address, b.City from DMD_Data.dbo.Brokers b", StrConn);
            SqlDataAdapter daUnassignedData1 = new SqlDataAdapter("select l.first_name, l.last_name,l.email_address from INTRANET.dbo.LO_INFORMATION l, DMD_Data.dbo.brokers b where b.brokers_id = l.broker_id", StrConn);
            daUnassignedData.SelectCommand.CommandType = CommandType.Text;
            daUnassignedData1.SelectCommand.CommandType = CommandType.Text;
            DataSet ds = new DataSet();
            daUnassignedData.Fill(ds, "brokers");
            daUnassignedData1.Fill(ds, "los");

            ds.Relations.Clear();
            ds.Relations.Add("rel", ds.Tables["brokers"].Columns["brokers_id"],
                ds.Tables["los"].Columns["broker_id"]);
            this.UltraWebGrid1.DataSource = ds.Tables["brokers"].DefaultView;
            this.UltraWebGrid1.DataBind();
ps. the broker_id in los dataset have null values

thanks
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Is 'broker_id' a primary key field in each table?  Relationships are built on primary keys, so if you don't have that, then you failed to respect good database design.  The DataSet class validates columns defined for DataRelation objects to make sure that they don't violate any rules for primary keys.

Bob
ASKER CERTIFIED SOLUTION
Avatar of dstanley9
dstanley9

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial