Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need to connect database from datasource...
can i connect to database without ado.net entity framework

please send me the link for database connection i am new in mvc application
Posted

Yes, You can. Check this URL

Using ASP.Net MVC with Classic ADO.Net[^]
 
Share this answer
 
You can connect to the database using the Entityframework also and specifying the connection strings in the Web.config.

XML
<connectionStrings>
    <!-- Database ConnectionString -->
    <add name="Context Name" connectionString="data source=(LOCAL);initial catalog=DATABASE NAME;integrated security=False;MultipleActiveResultSets=True;user id=**;Password=**;" providerName="System.Data.SqlClient" />
    <!-- Database EntityFramework ConnectionString -->
</connectionStrings>


The Username and Password should only be given if DB is accessed through SQL authentication.

Thanks
Hope this helps
 
Share this answer
 
v2
Yes, You can do it. Simple define connection string in web.config file and then Access using
ConfigurationManger
.

<connectionstrings>
<add name="DevelopmentConnectionString">
connectionString="Data Source=sandeepss-PC;Initial Catalog=Development;User ID=sa;
Password=*******" providerName="System.Data.SqlClient" />


Now string pass in your
SqlConnection
after that all is same as you do in asp.NET with ADO.NET object.

If your are working with Linq in MVC application then it can be helpful.

http://www.codeproject.com/Articles/720471/A-Simple-MVC-Application-using-LINQ-to-SQL
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900