javascript calls sqlserver data in browser

Create a new web page locally, and then by writing JavaScript code, you can directly operate the sqlserver database, isn't it awesome!

The prerequisites must be in ie before it can be used.

The following code is tested under Windows10 + IE 11 environment.

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<script type="text/javascript">
    var objdbConn = new ActiveXObject("ADODB.Connection");    
    var strdsn = "Provider=SQLOLEDB.1;Password=password;Persist Security Info=True;User ID=sa;Initial Catalog=master;Data Source=localhost\\SQL";   //You need to modify your own server address, user name, password   
    objdbConn.Open(strdsn);       
     document.write( " Update data successfully!<br> " );  
    objdbConn.Close(); 
</script>
</body>
</html>  

If the update data is displayed successfully on the web page, it means that the connection is successful. If the connection is unsuccessful, look at the developer tools. If it shows that the sqlserver does not exist or refuses, it means that this option is available. If there is a magical Automation server, it cannot be created. The object, very helpless, tried to modify the registry, set the security level of IE, adjust the ActiveX settings and other options, but they could not solve it.

Both my win10 and IE are the latest version.

Win10 is also 371, and it was successfully tested on a 309 version.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325074850&siteId=291194637