hi i want to show entire column data from sql and show in a single textbox with ","

Recommended Answers

All 5 Replies

well i don't do c# programing but i can just provide the logic behind this:-

retrieve data using select query and then concatente these column values. I think + may help you to do this(concatenate).

Get your results into a collection, then use String.Join

Well I'll assume you know how to extract the values from the DB with an SQL query. Once there it's rather easy

All you need to do is create a for loop, and extract each value and pass it into a string. Then have another string that you simply append to. Something along these lines

string tempString = "";
StringBuilder combinedString = new StringBuilder();

for(int i = 0; i < columnCount; i++)
{
    tempString = "extracted value from database is passed to this string";
        //replace that string with what is said

    combinedString.Append(tempString).Append(",");
}

textBox1.Text = combinedString.ToString();

I used StringBuilder because it works better for large amounts of data (I mean night and day difference).

Is this what yo uare asking

Did thie end up working for you?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.