Saturday, August 21, 2010

How can i retrieve data line by line from database in asp.net?

I store some poems in my database when i try to retrieve that poems on web page it looks like the paragraph, not like poems.


Can anyone tell me or send me code that how can i retrieve poems line by line. I am using vb.net.How can i retrieve data line by line from database in asp.net?
Perhaps do you have a delimeter for the poem? say comma or something so that it can clearly shows that when is the end of the line. for instance:


bla bla bla,


bla bla bla,


bla bla bla,


bla bla bla.





So when you store them into the table column, it will look something like:


bla bla bla, bla bla bla, bla bla bla, bla bla bla.





And this will be what you see as well when you display them out. If you have a delimeter like ';,'; in your poem, when you display out you can actually break them and store them into an array, and display them back in line by line. Code should look something like this:





Dim poem() as String = Split(xxx, ';,';)


Note: xxx is the source of your data from DB, it should look something like dataset.Tables(';poem';).rows(0).item(';col鈥?br>




Dim line1 as String = poem[0]


Dim line2 as String = poem[1]


Dim line3 as String = poem[2]


Dim line4 as String = poem[3]





Me.txtPoem.text = line1 %26amp; ';%26lt;br%26gt;'; %26amp; line2 %26amp; ';%26lt;br%26gt;'; %26amp; line3 %26amp; ';%26lt;br%26gt;'; %26amp; line4





I'm not sure is this what you want, hope it will help. And please note that this code will only works if you have only ONE comma in each line and the comma is located at the end of the line. (last line can have no comma at all) :)How can i retrieve data line by line from database in asp.net?
Change the DataBase field as text field.And Use Fck editor to write and save text.It will save exactly the same format u write on editor.Do some R%26amp;D.

No comments:

Post a Comment