ASP.net webpage and database

  • Thread starter Thread starter Beginner
  • Start date Start date
B

Beginner

Hello, I have an ASP.net webpage and I would like to include many articles
about trees.

I though about creating a SQL server database and bind it to my ASP.net
webpage. I know how to bind a database to ASP.net but I don't know if it is
a good idea to store the articles in my database as binary data (I think it
would be more efficient if I only store a pointer to it). What do you think?
XML maybe? I need examples because I'm a beginner.

My intention is that the ASP.net page receives a parameter (say
"ArticleID?=12345") and then loads the 12345 article from the database.

Thanks,
 
My intention is that the ASP.net page receives a parameter (say
"ArticleID?=12345") and then loads the 12345 article from the database.

This is a regular approach for all database-driven websites.
 
Sounds OK to me...

And should I store the articles as binary data in the database or should I
store them elsewere?

If you have links with code examples, I'd be grateful.

Thanks,
 
And should I store the articles as binary data in the database or should I
store them elsewere?

If you have links with code examples, I'd be grateful.

Thanks,




- Show quoted text -

Create a table Articles

Id int (as an identity column)
Text nvarchar(max)

then to insert data use

string text = "...text here....";
SqlConnection DataConnection = new SqlConnection(Connection);
string Command = "INSERT INTO Articles VALUES (@Text)";
SQLCommand DataCommand = new SqlCommand(Command, DataConnection);
DataCommand.Parameters.AddWithValue("@Text", text);
DataCommand.Connection.Open();
DataCommand.ExecuteNonQuery();
DataCommand.Connection.Close();

See more on MSDN or ASP.NET: http://quickstarts.asp.net/QuickStartv20/aspnet/doc/data/default.aspx

Hope this helps
 
Hi,

I would say that the formatting of the articles would dictate your method.
Do you need to maintain fonts and pictures? If so, storing the articles as
PDFs on the server, then referencing their ID in the database to grab the
location/file name then display accordingly. If you want to go this way, I
could cobble some psuedo code together for you. If you just need the text,
then a nvarchar() in the table will do the trick.

Craig




Beginner said:
Sounds OK to me...

And should I store the articles as binary data in the database or should I
store them elsewere?

If you have links with code examples, I'd be grateful.

Thanks,
 
Back
Top