日期:2014-05-18  浏览次数:20850 次

dataset里面的问题
弱弱的问下
C# code
                string mysql = "select * from carinfo";
                m_dataadapter = new SqlDataAdapter(mysql, m_connection);
                m_dataadapter.FillSchema(m_ds, SchemaType.Source, "carinfo");
                m_dataadapter.Fill(m_ds, "carinfo");


                mysql = "select * from cardinfo";
                m_dataadapter2 = new SqlDataAdapter(mysql, m_connection);
                m_dataadapter2.FillSchema(m_ds, SchemaType.Source, "cardinfo");
                m_dataadapter2.Fill(m_ds, "cardinfo");

                mysql = "select * from userinfo";
                m_dataadapter3 = new SqlDataAdapter(mysql, m_connection);
                m_dataadapter3.FillSchema(m_ds, SchemaType.Source, "userinfo");
                m_dataadapter3.Fill(m_ds, "userinfo");


userinfo.userID 与 cardinfo.userID ,cardinfo.ID与 carinfo.ID 可以关联
因为需要现在想把已经在dataset中的3个表再组合下成为一张表 放在dataset里行不行

------解决方案--------------------
C# code

string mysql="select * from cardinfo inner join carinfo on cardinfo.ID=carinfo.ID inner join userinfo on cardinfo.userID=userinfo.userID";
m_dataadapter = new SqlDataAdapter(mysql, m_connection);
m_dataadapter.FillSchema(m_ds, SchemaType.Source, "carinfo");
m_dataadapter.Fill(m_ds, "carinfo");

------解决方案--------------------
建议用 DataSetHelper ,里面支持对DataTable的 join,group ..
------解决方案--------------------
自己在DataSet中新增加一张表,然后通过Ado.net表达式实现,这样不需要管理数据同步,应该是比较好的一种解决方式,
http://www.microsoft.com/china/MSDN/library/data/dataAccess/ADONETEXP.mspx