返回首页

这最后一件事我做了


            con = new SqlConnection(str);

            con.Open();

            string custom_tb = "select branch_name,name,address,insurance_cost,record_date  from customers,branches where branches.code_branch=customers.code_branch ";

            string branches_tb = "select * from branches";

            string type_tb="select * from insurance_type";

            dset = new DataSet();

            da = new SqlDataAdapter(custom_tb , con);

            da.Fill(dset, "customers");

            da = new SqlDataAdapter(custom_tb, con);

            da.Fill(dset, "branches");

            da = new SqlDataAdapter(type_tb, con);

            da.Fill(dset, "insurance_type");

            builder = new SqlCommandBuilder(da);

            dset.Relations.Add ("branches_customers",dset.Tables ["branches"].Columns ["code_branch"],

            dset.Tables ["customers"].Columns ["code_branch"]);

 

            dset .Relations .Add ("insurance_type_customers",dset .Tables ["insurance_type"].Columns ["code_type"],

            dset .Tables ["customers"].Columns ["code_type"]);

            dataGridView1.DataSource = dset.Tables["customers"];

回答

评论会员: 时间:2
s