用JavaScript访问客户SQL Server数据库
http://tech.ddvip.com 2008年08月28日 社区交流
内容摘要:在SQL Server2000(其它版本没试过),且数据库必须安装了WMI扩展的情况下,用JavaScript访问客户SQL Server数据库。
JavaScript能访问客户SQL Server数据库?能。
要求:SQL Server2000(其它版本没试过),且数据库必须安装了WMI扩展(WMI SQL Server Administration Provider,能在SQL Server2000安装光盘的"x86otherwmi" 目录下找到)
好了,接下来我们试试代码吧:
<!DOCTYPE HTML PUBLIC "-//W3C//DTDHTML4.0Transitional//EN">
<html>
<head>
<title></title>
<metaname="GENERATOR"content="MicrosoftVisualStudio.NET7.1">
<metaname="vs_targetSchema"content="http://schemas.microsoft.com/
intellisense/ie5">
<scriptid="clientEventHandlersJS"language="javascript">
<!--
functionButton1_onclick(){
varlocator=newActiveXObject("WbemScripting.SWbemLocator");
varservice=locator.ConnectServer(".","rootMicrosoftSQLServer");
varproperties=service.ExecQuery("SELECTNameFROMMSSQL_Database");
vare=newEnumerator(properties);
document.write("<tableborder=1>");
dispHeading();
for(;!e.atEnd();e.moveNext())
{
varp=e.item();
document.write("<tr>");
document.write("<td>"+p.Name+"</td>");
document.write("<td>"+p.SQLServerName+"</td>");
document.write("</tr>");
}
document.write("</table>");
}
functiondispHeading()
{
document.write("<thead>");
document.write("<td>Name</td>");
document.write("<td>SQLServerName</td>");
document.write("</thead>");
}
//-->
</script>
</head>
<body> <INPUTid="Button1"type="button"value="Button"name="Button1"
language="javascript"onclick="returnButton1_onclick()">
</body>
</html>
呵呵,虽然也许没有什么实用价值,但JavaScript竟能访问SQL Server数据库,确实令人惊叹!
作者:LanceZhang 责编:豆豆技术应用
- SQL Server 2008 教程
- SQL Server 2005 教程
- SQL Server 安全设置
- SQL Server 故障解决
- SQL Server 安装配置
- SQL Server 备份恢复
- SQL Server 性能调优
- SQL Server 存储过程
- SQL Server 函数
- SQL Server 事务
- SQL Server 查询
- SQL Server 索引
- SQL Server 入门教程
- SQL Server 数据类型
- SQL Server 数据库表
- SQL Server T-SQL
- SQL Server 语句
- SQL Server 死锁
- SQL Server 加密
- SQL Server 数据库连接
- SQL Server 数据仓库
- SQL Server 数据库管理
- 更多SQL Server 专题>>>