1

I'm used to PHP style MVC frameworks which are a little different from the way ASP's MVC frameworks work.

Is there a built in database class? Or do I need to code my own database class using a web.conf connection string?

With PHP's MVC frameworks you simply add your database connection information into a database and then query it with something like:

$results = $this->db->query("select * from table");

2 Answers 2

2

It is not quite that simple, but you have a lot more flexibility. Check this link out: http://www.dotnetperls.com/sqlconnection -- It has some getting started for doing exactly what you've outlined (though I HIGHLY recommend you use sprocs or at a minimum, paramaterized sql, not direct sql).

With that said, I suggest you look into Linq-To-SQL or Entity Framework. Any on-line sampels you find will probably use one of these technologies, and they do make things very nice and simple.

Sign up to request clarification or add additional context in comments.

1 Comment

-1 for preaching old technologies. If you don't want to use an ORM, then at least use ADO.NET - the most recent data access technology. In this case 'DbConnection' instead of 'SqlConnection'.
1

Use an ORM like Entity Framework 4.1 or nHibernate. They will handle the database connection internally and therefore abstract away some of the complexities of safely opening/closing connections. Then all you need to provide is a connection string.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.