簡體   English   中英

將 JavaScript function 的值插入 SQL 服務器數據庫

[英]Insert the value of a JavaScript function to an SQL Server database

是否可以在 SQL 服務器數據庫數據庫中添加 JavaScript 變量(運行 SQL 查詢或存儲過程)? 如果是這樣,怎么做?

僅使用 JavaScript,不,您不能(當然,除非您使用的是Node.js )。

關鍵是,您需要一些服務器端代碼來與數據庫交互。 You can use JavaScript in the browser to make an Ajax call to a server-side script ( PHP , Ruby , Python , ASP.NET , Node.js, etc.) that performs the interaction with the database.

您無法從 JavaScript 訪問數據庫。 您需要將數據發送到 PHP、 Ruby on RailsASP.NET或您用於實現后端的任何東西。

您可以使用 Ajax 發布到某種類型的 web 服務(或任何其他服務器端腳本)以傳遞 JavaScript 值。 web 服務將訪問數據庫並將其保存...

您可以從 Node.js 中的 JavaScript 輕松訪問數據庫

If you're doing it from the browser, you'll most definitely need some kind of mid-tier service which translates HTTP queries to the relevant database driver (you can write that in any language you want - PHP , JavaScript, ASP.NET , etc .)。

在隱藏字段中設置變量的值,並在提交表單時在服務器端獲取該字段的值並將其保存到數據庫中......

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM