Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8979

3 rows data into one column

$
0
0

Hi,

Im working with asp application having controls (1 dropdownlist(options--Schedlue,InProcess,On HOld),two textboxes(SSStatusComments,SSGeneralComments))  I want to show output something  like below

CREATE TABLE [dbo].[EFIWorkStatus1](
	[WID] [int] IDENTITY(1,1) NOT NULL,
	[ST_ID] [int] NULL,
	[SSStatus] [nchar](10) NULL,
	[SSStatusComments] [nvarchar](max) NULL,
	[SSGeneralComments] [text] NULL) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
 private void SiteSurveystatusload()
    {
        using (SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ArgentDB"].ConnectionString))
        {
            cn.Open();

            string sql = "Select  SSStatus,SSStatusComments from EFIWorkStatus1 where  ST_ID=@ST_ID";

            SqlCommand cmd = new SqlCommand(sql, cn);
           cmd.Parameters.AddWithValue("@ST_ID", Request.QueryString["ID1"]);
            using (SqlDataReader reader = cmd.ExecuteReader())
            {
                if (reader.HasRows)
                {


                    while (reader.Read())
                    {

                        txt_SiteSurveyGeneralComments.Text = reader["SSStatus"].ToString() + " " + reader["SSStatusComments"].ToString();
                    }
                }
                else
                {
                    txt_SiteSurveyGeneralComments.Text = "";
                }

            }
        }

    }


output in database  for  above   code 
WID    ST_ID    SSStatus          SSStatusComments  SSGeneralComments 
1	4	Schedule  	test in schedule	Select    		   
2	4	In Process	test in process		Select    	//expected output Schedule  test in schedule  in SSGEneralComments			
3	4	On Hold   	ite on hold	  On Hold    ite on hold   //expected output   Schedule  test in schedule  In Process test in process in GeneralComments



Viewing all articles
Browse latest Browse all 8979

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>