且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我想从SQL Server数据库中获取数据

更新时间:2023-01-30 11:57:41

1)ActiveXObject(ADODB.Recordset)通常不可用(当然在所有我的系统) - 并且'斑点'可用性使它无用。



2)这将教你如何: PHP 5教程 [ ^ ] PHP是一种非常广泛使用的服务器端语言。



在他们谈论访问MySQL的教程中 - 有插件驱动程序可用来自Microsoft提供对SQL的php访问。 从官方Microsoft下载中心下载适用于SQL Server的PHP的Microsoft驱动程序 [ ^ ]



你会注意到php与javascript并没有太大的不同 - 至少在于它遵循C语法,如果你已经学过'C'那么你就知道了很多它的库已经。





这是获取数据的好方法,非常感谢你。

i tried to get data from sql server database using javascript in html


<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Database Connect</title>
    <script type="text/javascript">

        var connection = new ActiveXObject("ADODB.Connection");

        var connectionstring = "Data Source=GD-04\SQLEXPRESS;Initial Catalog=Employee;User ID=sa;Password=grassdew;Provider=SQLOLEDB";

        connection.open(connectionstring);
        var rs = new ActiveXObject("ADODB.Recordset");
        var strQuery = "SELECT * FROM Customer_Orders";
        rs.Open(strQuery, connection);
        rs.MoveFirst();
        while (!rs.EOF) {
            document.write(rs.fields(0) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
            document.write(rs.fields(1) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
            document.write(rs.fields(2) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
            document.write(rs.fields(3) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
            document.write(rs.fields(4) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
            document.write(rs.fields(5) + "<br/>");
            rs.movenext();
        }

        rs.close();
        connection.close();


    </script>
</head>
<body>
    <div id="main"></div>
</body>
</html>

1) ActiveXObject("ADODB.Recordset") is generally unavailable (certainly on all of my systems) - and 'spotty' availability makes it useless.

2) This will teach you how: PHP 5 Tutorial[^] PHP is a very widely available server-side language.

inside the tutorial they talk about accessing MySQL - there are plug-in drivers available from Microsoft for giving php access to SQL. Download Microsoft Drivers for PHP for SQL Server from Official Microsoft Download Center[^]

You'll notice that php isn't a whole lot different than javascript - at least in that it's follows C syntax, and if you've ever learned 'C' then you know a lot of it's library, already.



It is great memthod to get data, thank you a lot.