question

NM-0091 avatar image
0 Votes"
NM-0091 asked CarrinWu-MSFT commented

Connecting a SQL db from HTML/Javascript

Hello,

I am looking for a simple query to connect to a SQL server DB in Windows authentication mode from an HTML form.
Experts please suggest.

Thanks,
NM

sql-server-general
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You cannot. Where is the SQL Server Database? If it is in the server then it is in a totally different system than the browser and JavaScript. Even if the database is in the same system as the browser and JavaScript, SQL Server has no way of authenticating the request and you can instead use a desktop application.

0 Votes 0 ·

Hi, we have not get a reply from you. Did the answers could help you? If there has an answer helped, do "Accept Answer". If it is not work, please let us know the progress. By doing so, it will benefit all community members who are having this similar issue. Your contribution is highly appreciated.

0 Votes 0 ·

1 Answer

CarrinWu-MSFT avatar image
0 Votes"
CarrinWu-MSFT answered SimpleSamples commented

Hi @NM-0091,

There is no common way to connect to SQL Server database from JavaScript client, every browser has its own API and packages to connect to SQL Server. It is not recommended to use JavaScript clients to access databases for several reasons. Please refer to How to connect SQL Server database from JavaScript in the browser ? get more details.


Best regards,
Carrin


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

And ActiveXObject is only supported in Internet Explorer. That is the only possible solution suggested by that article for use within a browser. As stated by that article, there are serious security vulnerabilities by the use of JavaScript clients (in browsers) to access databases.

0 Votes 0 ·