Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jun 20, 2012 05:01 PM by bkis1112
Jun 20, 2012 04:34 PM|LINK
I'm confused as to how to connect to and query a MS SQL DB using MVC. I configured the web.config file with the following info:
connectionString="data source=sqlserver;initial catalog=sweepdb;user id=sysupdate;password=password;"
Then, from what I have read, I cretae a new model, sweepmodel.cs, and query the DB within this file. I don't know how to do this... Do I reference the name, sweepDB?
Sorry, I just realized this sounds like such a basic question, but I am just getting into ASP MVC and it seems to be a little confusing.
Jun 20, 2012 04:43 PM|LINK
no we dont connect to DB in Model there should be a business layer from which we call the database or service and do other logics and create the instance of the model and populate the data into it
to access sweepDB need to add reference to System.ConfigurationManager and inside code access it
Jun 20, 2012 05:01 PM|LINK
Using ADO.NET Entity Framework to connect with data, generate model
Using Linq to query database
Thanks for reading my post