如何获得数据库表中某一字段中的以逗号分开的内容?

存储过程:

alter procedure sp_Tased
as
select FileUrl from tas where Sid=3

 

BLL层:unnions.cs

        public string Unions_Sel()
        {
            List list = null;
            unionsInfo info = null;
            using (SqlDataReader reader = SqlHelper.ExecuteReader(CommandType.StoredProcedure, "sp_Tased", null))
            {
                if (reader != null)
                {
                    list = new List();
                    while (reader.Read())
                    {
                        info = new unionsInfo()
                        {
                          
                            FileUrl = reader.GetString(0)
                        };
                        list.Add(info);
                    }
                }
            }
            return info.FileUrl;
        }

 

UI层:unionSelect.aspx

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="unionSelect.aspx.cs" Inherits="unionSelect" %>



   


   


   

       

   

   



 

 

后台:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using BLL;

public partial class unionSelect : System.Web.UI.Page
{
    private unions union = new unions();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BinGrid();           
        }       
    }
    private void BinGrid()
    {
       string str = union.Unions_Sel();
       string[] s = str.Split(',');
       a.Text = s[2];
    }
}

 

 

 适用范围:仅能选择出字段中的一条记录,不能把该字段中的所有记录都选出来。

 

你可能感兴趣的:(asp.net)