Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello experts,

i am fetching data from database and in loop i want to append the richtextbox.rtf:

String lsVal = String.Empty;
for (int i = 0; i < lobjDS.Tables[0].Rows.Count; i++)
                    {
                        Byte[] data = (Byte[])(lobjDS.Tables[0].Rows[i]["QUESTION"]);

                        lsVal += Encoding.Unicode.GetString(data);                        
                    }
                    richTextBox2.Rtf = lsVal;


this code is showing only first record.
help me to get all the records from data base to richtextbox.

What I have tried:

above written code i have tried but it is shoing only the first record.
Posted
Updated 20-Jan-17 0:29am

1 solution

We can't tell you exactly what to do - we don't have your data, so we can't test your code under the same circumstances as you can.
So, its going to be up to you.
Put a breakpoint on the first line you show, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!

But why are you storing the RTF data in byte array (or a VARBINARY column if you get it from a DB)? It's text if it's RTF data, so use a string (or a NVARCHAR column) and just cast it directly to a string.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900