C# 中有关数据库中数据的操作中,能否自连接

          

        #region-------从数据库中得到候选一项集---------
        ///
        /// 从数据库中得到候选一项集
        ///
        static ArrayList GetItems1FromDB()
        {
            string commandString = "select * from View_sales98";
            //string commandStringT = "select time_id from View_sales98";
            //string commandStringS = "select 商品_ID from View_sales98";

            DataSet ds = ExcuteDataSetByCommandString(commandString);
            //DataSet dsT = ExcuteDataSetByCommandString(commandStringT);
           // DataSet dsS = ExcuteDataSetByCommandString(commandStringS);

 

 

 

 

客户-idtime-id商品id
1134
1145
2256
2467
如图上的交易表,我如何把同一个顾客同一时间买的商品id提取在一个数组里面,

我想用一个二维数组a[客户列][商品列]来表示。

        #region-------从数据库中得到候选一项集---------
        ///
        /// 从数据库中得到候选一项集
        ///
        static ArrayList GetItems1FromDB()
        {
            string commandString = "select * from View_sales98";
            //string commandStringT = "select time_id from View_sales98";
            //string commandStringS = "select 商品_ID from View_sales98";

            DataSet ds = ExcuteDataSetByCommandString(commandString);
            //DataSet dsT = ExcuteDataSetByCommandString(commandStringT);
           // DataSet dsS = ExcuteDataSetByCommandString(commandStringS);
            int countItems1 = 0;
            countItems1 = ds.Tables[0].Rows.Count;

            ArrayList Items1 = new ArrayList();

            for (int i = 0; i < countItems1; i++)
            {
                string kehui = ds.Tables[0].Rows[i]["客户_ID"].ToString();
                string timei = ds.Tables[0].Rows[i]["time_id"].ToString();
                for (int j = 1; j < countItems1&&i!=j; j++)
                {
                    string kehuj = ds.Tables[0].Rows[j]["客户_ID"].ToString();
                    string timej = ds.Tables[0].Rows[j]["time_id"].ToString();
                    if (kehui == kehuj && timei == timej)
                    {
                        Items1.Add(ds.Tables[0].Rows[i]["商品_ID"].ToString());
                    }
                }
            }
            return Items1;
        }
        #endregion-------从数据库中得到候选一项集---------

 

上述程序能不能实现呢?

有没有高人给我点建议啊

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值