0

Hello all
I am writing a solicitor allocation application that will be used by multiple users at one time.
Because of this, the database needs to be updated with every change.
This is my code when a solicitor is chosen for allocation:

private void FindSolicitor(int type, bool stype)
        {
            table = "";
            row = 0;

            int t = 0;
            bool f = false;
            string s = "";

            char ctype = char.Parse(type.ToString());

            if (!stype)
            {
                t = 0;
                for (int i = 0; i < sadset.Tables["Solic"].Rows.Count; i++)
                {
                    if (sadset.Tables["Solic"].Rows[i]["State"].ToString() == "0" && ((sadset.Tables["Solic"].Rows[i]["Types"].ToString()).Contains(ctype)))
                    {
                        f = true;
                        sadset.Tables["Solic"].Rows[i]["State"] = 1;
 >>                     adsol.Update(sadset.Tables["Solic"]);

                        s = (string)sadset.Tables["Solic"].Rows[i]["Solicitor"];

                        table = "Solic";
                        row = i;
                        break;
                    }
                }
            }
            else
            {
                switch (exn)
                {
                    case (5):
                        t = 1;
                        for (int i = 0; i < sadset.Tables["Solicminor"].Rows.Count; i++)
                        {
                            if ((int)sadset.Tables["Solicminor"].Rows[i]["State"] == 0)
                            {
                                f = true;
                                sadset.Tables["Solicminor"].Rows[i]["State"] = 1;
 >>                             admin.Update(sadset.Tables["Solicminor"]);

                                s = (string)sadset.Tables["Solicminor"].Rows[i]["Solicitor"];

                                table = "Solicminor";
                                row = i;
                                break;
                            }
                        }
                        break;

                    case (6): // LQU goes to Bakers
                        t = 2;
                            if ((int)sadset.Tables["Solic"].Rows[1]["State"] == 0)
                            {
                                f = true;
                                sadset.Tables["Solic"].Rows[1]["State"] = 1;
 >>                             adsol.Update(sadset.Tables["Solic"]);

                                s = (string)sadset.Tables["Solic"].Rows[1]["Solicitor"];

                                table = "Solic";
                                row = 1;
                                break;
                            }
                        break;
                }
            }

            if (!f)
                Reset(t);
            else
            {
                active = true;
                lbsol.Text = s;
                p.Visible = true;
            }
        }

Every single time one of the Update commands is executed, DBConcurrency Exception is thrown. There is no declared update command; i have had no trouble in the past just using the autogenerated command.

Thanks in advance for any help

1
Contributor
1
Reply
2
Views
4 Years
Discussion Span
Last Post by //Gonz
0

SORTED IT!

This was caused by a dataset.AcceptChanged(); before the initial code.

Sorry for being an idiot guys

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.