标题:如何读取数据库同一列里符合要求的多行数据
取消只看楼主
wuqinghao10
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-1-16
结帖率:0
 问题点数:0 回复次数:0 
如何读取数据库同一列里符合要求的多行数据
举例:
public string getAccessories(string productName, int pnPass1, int pnPass2)
        {
           string accessories = "";

            SQLiteConnection conn = new SQLiteConnection("Data Source=database/HexSettings.db;");
            conn.Open();
            SQLiteCommand cmd = new SQLiteCommand(conn);

            if (productName.Contains("A"))
            {
                = "select CC from List1 where ProductName ='" + productName + "' and LPN =" + pnPass1 + " and HPN =" + pnPass2;
            }
            else
            {
                = "select CC from List2 where ProductName ='" + productName + "' and PNPass1 =" + pnPass1 + " and PNPass2 =" + pnPass2;  
            }
             = CommandType.Text;
            SQLiteDataReader dr = cmd.ExecuteReader();

            if (dr.Read())
            {
                accessories = dr[0].ToString();
            }

            dr.Close();

            return accessories;

        现在我只能读取符合要求的第一个值,请问各位如何修改可以读取符合要求的所有值
谢谢!!
搜索更多相关主题的帖子: database 数据库 public where 数据库 database public where 
2013-05-15 11:21



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-407126-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.893104 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved