topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Wednesday December 11, 2024, 2:49 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Best Approach to store and load a lot of text snippets into a web page  (Read 5088 times)

BGM

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 563
    • View Profile
    • bgmCoder DC
    • Read more about this member.
    • Donate to Member
My project is a web-application that I'm writing using C# webforms.
I have a few hundred small text blocks - (actually prayers) that I want to load into the web page and arrange so the user can easily find what they want.

Now, my question is how to store them.
I could put them in XML or an access database or a sql database, or I can just type them all right into the web page.

The thing is that if I put them in a database, I can enclose everything in the proper divs that the webpage needs to display them with sortable jquery menus and accordians.  If I typed them into the webpage, it would be hard to know what is in the page, exactly, and I'd have to type all the divs.  So, I'm leaning toward a database or xml for storing the prayers with their titles, imprimaturs, and perhaps comments.

Should I use xml, sql or accdb for storing things?  Which would be faster to load and search?

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
I don't know a great answer to this, but one compromise option might be like this:

Use a javascript data table script, where you can provide your text data as json data embedded in the page itself.

The advantages of this are:

1. The text block data is clean data that you could use in a different way with any script or standalone application that can load json, and its not hardcoded as html text on a page, and it would be easy to convert the data to different formats later.
2. The data table script can let people do things like sort, search,etc.

BGM

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 563
    • View Profile
    • bgmCoder DC
    • Read more about this member.
    • Donate to Member
Mouser,  so, I considered json, but I hate dealing with all those quotation marks.  XML, I decided was clumsy.  I ended up trying my hand at a sqlite.  I was reading that it has a performance superiority over json or xml, and I want to easily add more items.  Plus, I can use a type:text and store literal carriage returns.  In json or xml I'd have to always keep typing escape characters.

So, in C#, I just query the sqlite db into a datatable and then I can regex replace \r\n with <br/>.
And, as you said, I can store all the prayers in plain old text in the db and be able to use it for other applications, too, if I want.
Finally, I went with a .db because if I get up into having 500 prayers in the database, it will be much more manageable than a giant json file.

Thanks for your tips, though, even though I already decided what to do before you posted...   :D