我需要在MVC中连接数据库连接 [英] i need to connect database connection in MVC
问题描述
我需要从数据源连接数据库...
我可以连接到没有ado.net实体框架的数据库
请发送我是数据库连接的链接我是mvc应用程序中的新东西
是的,你可以。查看此URL
将ASP.Net MVC与经典ADO.Net结合使用 [ ^ ]
您也可以使用Entityframework连接数据库并在Web.config中指定连接字符串。
< connectionStrings >
<! - 数据库连接字符串 - >
< add 名称 = 上下文名称 connectionString = data source =(LOCAL); initial catalog = DATABASE NAME; integrated security = False; MultipleActiveResultSets = True;用户ID = **;密码= **; providerName = System.Data.SqlClient / >
<! - Database EntityFramework ConnectionString - >
< / connectionStrings >
只有在通过SQL身份验证访问数据库时才能提供用户名和密码。
谢谢
希望这有帮助
是的,你可以做到。在web.config文件中简单定义连接字符串,然后使用ConfigurationManger进行访问。
< connectionstrings>
< add name =DevelopmentConnectionString>
connectionString =数据源= sandeepss-PC;初始目录=开发;用户ID = sa;
密码= *******providerName =System.Data.SqlClient/>
现在字符串传入你的SqlConnection之后,所有内容与使用ADO.NET对象的asp.NET相同。
如果您在MVC应用程序中使用Linq,那么它可能会有所帮助。
http://www.codeproject.com/Articles/720471/A-Simple- MVC-应用程序使用-LINQ到SQL
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
Yes, You can. Check this URL
Using ASP.Net MVC with Classic ADO.Net[^]
You can connect to the database using the Entityframework also and specifying the connection strings in the Web.config.
<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
Yes, You can do it. Simple define connection string in web.config file and then Access usingConfigurationManger.
<connectionstrings>
<add name="DevelopmentConnectionString">
connectionString="Data Source=sandeepss-PC;Initial Catalog=Development;User ID=sa;
Password=*******" providerName="System.Data.SqlClient" />
Now string pass in yourSqlConnectionafter 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
这篇关于我需要在MVC中连接数据库连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!