简体   繁体   English

如何将 html 页面连接到 Microsoft SQL 服务器?

[英]How can i connect a html page to a Microsoft SQL Server?

I am currently working on a html web page that is supposed to visualize the data (with tables, charts, graphs...) saved in a SQL database which lies on a local Microsoft SQL Server 2014 . I am currently working on a html web page that is supposed to visualize the data (with tables, charts, graphs...) saved in a SQL database which lies on a local Microsoft SQL Server 2014 .

Is there a common practise to connect the web page to this server ?是否有将 web 页面连接到此服务器的常见做法? I stumbled upon node.js and ajax, but i could not manage to find a proper way to get the data out of the database.我偶然发现了 node.js 和 ajax,但我找不到合适的方法将数据从数据库中取出。

I'm completely new to this topic since i never had to back up a webpage dynamically by connecting to a database so please take me there in baby steps:)我对这个主题完全陌生,因为我从来不需要通过连接到数据库来动态备份网页,所以请带我去那里:)

So far, i'm using nothing else but jQuery.到目前为止,我只使用了 jQuery。

Thank you in advance先感谢您

The most basic way is to install XAMPP on your server.最基本的方法是在您的服务器上安装XAMPP On it's official site there are manuals to installing and configuring it.在它的官方网站上有安装和配置它的手册。

To connect PHP to SQL Server your will need to install proper drivers (check PHP version, x64/x86 etc on ' details ' part of page).要将 PHP 连接到 SQL 服务器,您需要安装正确的 驱动程序(检查 PHP 版本、x64/x86 等页面的“详细信息”部分)

Basic info how to connect to SQL Server you can find on web or, for example, here to connect via PDO, and here to connect via SQLSRV.关于如何连接到 SQL 服务器的基本信息,您可以在 web 上找到,或者,例如,这里通过 PDO 连接,这里通过 SQLSRV 连接。

After on installations and configuring is done - you need to create PHP page that will take data from SQL Server and show it to user in proper way.安装和配置完成后 - 您需要创建 PHP 页面,该页面将从 SQL 服务器获取数据并以正确的方式显示给用户。

EDIT编辑

I forgot about SSRS (SQL Server Reporting Services) Here is an old good guide how to use it.我忘记了SSRS (SQL Server Reporting Services)这是一个古老的好指南如何使用它。

"Hi, you can do this by creating a DSN using ODBC Data Source: “您好,您可以使用 ODBC 数据源创建 DSN:

  1. In the Visual Studio IDE, right click on ""Data Connections"" in the Server Explorer在 Visual Studio IDE 中,右键单击服务器资源管理器中的“数据连接”
  2. When ""Add Connection""opens, browse for the server from which the data to be pulled from and displayed.当“添加连接”打开时,浏览要从中提取和显示数据的服务器。
  3. Now open the ODBC Source Administrator: Start |现在打开 ODBC 源管理员:开始 | All Programs |所有程序 | Control Panel |Administrative Tools |控制面板 |管理工具 | Data Sources(ODBC)数据源 (ODBC)
  4. Select the DSN tab and click ""Add"". Select DSN 选项卡并单击“添加”。 In the ""Create New Data Source"" window, scroll down to SQL Server Native Client 10.0在“创建新数据源”中window,向下滚动到SQL Server Native Client 10.0
  5. Select the proper parameters and click ""Finish"" Select 正确的参数并单击“完成”
  6. Now open Visual Studio IDE and drag a Gridview control from the tool.现在打开 Visual Studio IDE 并从工具中拖动 Gridview 控件。
  7. Click ""New data source"" from the grid and select the database from the template单击网格中的“新数据源”和模板中的数据库 select
  8. Click ""New connection"" and select Microsoft ODBC Data source.点击“新建连接”,select Microsoft ODBC 数据源。 Browse to the newly created DSN.浏览到新创建的 DSN。
  9. By assigning proper binding column to the grid the data can be displayed in the html grid.通过为网格分配适当的绑定列,数据可以显示在 html 网格中。 " "

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM