[英]How to connect ASP.NET project with SQL Server database table in Visual Studio (C#)
I have created simple database table in Visual Studio 2015 called Users
and updated it. 我已经在Visual Studio 2015中创建了一个名为
Users
简单数据库表,并对其进行了更新。
I want to connect it with my project, so after I fill in my text fields and press 'Sign Up' button, it can get saved to database. 我想将其与我的项目连接,因此在填写文本字段并按“ Sign Up”按钮后,它可以保存到数据库。 I am aware that I'll have to use string connections and other stuff to connect it, but how do I first connect this project with
web.config
? 我知道我将必须使用字符串连接和其他东西来连接它,但是如何首先将该项目与
web.config
连接起来?
I have seen people dragging this table to Registration form code, so it would automatically create a connection with web-config, but it didn't work for me. 我见过有人将此表拖到“注册”表单代码中,因此它将自动使用web-config创建连接,但对我而言不起作用。
How do I reference my database from web.config
correctly ? 如何正确地从
web.config
引用我的数据库?
Right-click on MyDatabase.mdf and in the properties panel you will see the Connection String. 右键单击MyDatabase.mdf,然后在属性面板中将看到“连接字符串”。 Copy that into the web config in the ConnectionStrings node:
将其复制到ConnectionStrings节点的Web配置中:
<connectionStrings>
<add name="MyDatabase" connectionString="[Paste Connection String Here]"/>
</connectionStrings>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.