如何将数据从ASP.NET页面的表单插入Azure SQL数据库? [英] How do I insert data from a ASP.NET page's form to a Azure SQL Database?

查看:49
本文介绍了如何将数据从ASP.NET页面的表单插入Azure SQL数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含注册页面的ASP.NET Web应用程序项目。我已经成功地将我迄今为止所做的工作发布到Azure,并且可以通过azure项目链接访问它们。现在我需要将这些值从Signup表单插入我在门户网站上创建的Azure SQL数据库。



我在azure门户上创建了数据库,创建了桌子也是。我该如何插入?它是传统的SQL插入语句吗?

解决方案

是的,SQL始终是您在不同的数据库相关应用程序中学习和使用的SQL。但是,您唯一需要担心的是配置连接到Azure SQL数据库服务的应用程序。



在web.config文件中,您可以设置所有配置设置;包括与数据库的SQL连接。来自此MSDN文档 [ ^ ],您将以这种方式指定数据库的连接字符串,



 <   connectionstrings  >  
< add name = SQLAzureConnection connectionstring = 数据源=< ProvideServerName> .database.windows.net;初始目录= TestDb;用户ID =< ProvideUserName> ;;密码=< P rovidePassword> ;; Encrypt = true; Trusted_Connection = false;

providerName = 系统.Data.SqlClient / >
< / add > < / connectionstrings >





现在填写这些值,服务器名称和其他基本信息,如数据库名称和用户名/密码组合网站(在天蓝色的服务上ER)。


I have a ASP.NET Web Application project which contains a Signup page. I have successfully published the work I've done so far to Azure and they are accessible through the azure project link. Now I need to insert those values from the Signup form to an Azure SQL Database I have created on the portal.

I have created the DB on azure portal, created the tables as well. How do I insert? Is it the traditional SQL insert statements?

解决方案

Yes, the SQL is always the very same SQL that you learn and use in different database-related applications. However, the only thing you should worry about is the configuration of your application to connect to the Azure SQL database services.

In your web.config file, you can set all of the configuration settings; including the SQL connections to database. From this MSDN documentation[^], you would specify the connection string for your database in such a way,

<connectionstrings>
  <add name="SQLAzureConnection" connectionstring="Data Source=<ProvideServerName>.database.windows.net;Initial Catalog=TestDb;User ID=<ProvideUserName>;Password=<ProvidePassword>;Encrypt=true;Trusted_Connection=false;"

    providerName="System.Data.SqlClient" />
</add></connectionstrings>



Now fill these values, the servername and other basic information like the database name and the username/password combination for your website (on the azure server).


这篇关于如何将数据从ASP.NET页面的表单插入Azure SQL数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆