Пример #1
0
    // 查询多行数据
    public static ResultObject GetResult(string sql)
    {
        SqlDataReader r = null;

        try
        {
            r = GetReader(sql);
            ResultObject result = new ResultObject();
            while (r.Read())
            {
                RowObject row = new RowObject();
                for (int i = 0; i < r.FieldCount; i++)
                {
                    row.Add(r.GetName(i), r.GetValue(i));
                }
                result.Add(row);
            }
            return(result);
        }
        finally
        {
            if (r != null)
            {
                r.Close();
            }
        }
    }