在IE中直接连接SQL数据库
来源:互联网 发布:windows是什么操作系统 编辑:程序博客网 时间:2024/04/28 01:02
使用ODC文档
使用一个ODC文档可以很轻松在IE浏览器中连接到SQL SERVER数据库的表,ODC文档示例如下:
<html>
<head>
<meta http-equiv=Content-Type content="text/x-ms-odc; charset=utf-8">
<meta name=ProgId content=ODC.Table>
<meta name=SourceType content=OLEDB>
<meta name=Catalog content=K0712>
<meta name=Schema content=dbo>
<meta name=Table content="T_Material">
<xml id=docprops></xml><xml id=msodc><odc:OfficeDataConnection
xmlns:odc="urn:schemas-microsoft-com:office:odc"
xmlns="http://www.w3.org/TR/REC-html40">
<odc:Connection odc:Type="OLEDB">
<odc:ConnectionString>Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Data Source=develop;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=DEVELOP;Use Encryption for Data=False;Tag with column collation when possible=False;Initial Catalog=K0712</odc:ConnectionString>
<odc:CommandType>Table</odc:CommandType>
<odc:CommandText>"K0712"."dbo"."ICInventory"</odc:CommandText>
</odc:Connection>
</odc:OfficeDataConnection>
</xml>
<style>
<!--
.ODCDataSource
{
behavior: url(dataconn.htc);
}
-->
</style>
</head>
<body onload='init()' scroll=no leftmargin=0 topmargin=0 rightmargin=0 style='border: 0px'>
<table style='border: solid 1px threedface; height: 100%; width: 100%' cellpadding=0 cellspacing=0 width='100%'>
<tr>
<td id=tdName style='font-family:arial; font-size:medium; padding: 3px; background-color: threedface'>
</td>
<td id=tdTableDropdown style='padding: 3px; background-color: threedface; vertical-align: top; padding-bottom: 3px'>
</td>
</tr>
<tr>
<td id=tdDesc colspan='2' style='border-bottom: 1px threedshadow solid; font-family: Arial; font-size:
</td>
</tr>
<tr>
<td colspan='2' style='height: 100%; padding-bottom: 4px; border-top: 1px threedhighlight solid;'>
<div id='pt' style='height: 100%' class='ODCDataSource'></div>
</td>
</tr>
</table>
<script language='javascript'>
function init() {
var sName, sDescription;
var i, j;
try {
sName = unescape(location.href)
i = sName.lastIndexOf(".")
if (i>=0) { sName = sName.substring(1, i); }
i = sName.lastIndexOf("/")
if (i>=0) { sName = sName.substring(i+1, sName.length); }
document.title = sName;
document.getElementById("tdName").innerText = sName;
sDescription = document.getElementById("docprops").innerHTML;
i = sDescription.indexOf("escription>")
if (i>=0) { j = sDescription.indexOf("escription>", i + 11); }
if (i>=0 && j >= 0) {
j = sDescription.lastIndexOf("</", j);
if (j>=0) {
sDescription = sDescription.substring(i+11, j);
if (sDescription != "") {
document.getElementById("tdDesc").style.fontSize="x-small";
document.getElementById("tdDesc").innerHTML = sDescription;
}
}
}
}
catch(e) {
}
}
</script>
</body>
</html>
这样,可以很方便的在Web页面上显示数据表了J
会Web编程的都知道其实是一个HTML文本,采用Javascript来初始化窗口布局,加粗的部分是数据连接的关键部分,如下所示:
<odc:ConnectionString>Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Data Source=develop;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=DEVELOP;Use Encryption for Data=False;Tag with column collation when possible=False;Initial Catalog=K0712</odc:ConnectionString>
<odc:CommandType>Table</odc:CommandType>
<odc:CommandText>"K0712"."dbo"."ICInventory"</odc:CommandText>
其中,odc:ConnectionString是数据库连接串,使用和ADO一样的格式,不用多说了吧J;odc:CommandType是查询类型,Table是表查询,SQL是标准SQL语句查询;odc:CommandText是查询命令文本,如果是Table类型的,就只要写出表名称就可以了,如master.dbo.sysobjects,如果是SQL类型的话,就是一般的SQL语句,如“SELECT t0.*FROM ICStockBill t0 INNER JOIN ICStockBillEntry t1 ON t0.FStockBillID=t1.FstockBillID ORDER BY t0.FStockBillID”
- 在IE中直接连接SQL数据库
- 在IE中直接连接SQL数据库
- 在IE中直接连接SQL数据库
- 在C#中连接SQL数据库
- 在 IE 中直接查看PDF文件
- vbscript本地文件直接连接sql数据库
- 写一个能直接执行的.sql文件,如何在这里连接数据库?
- javascript连接远程数据库SQL Server 2014(只能在IE浏览器上运行)
- 如何把代码中的SQL语句改成可以直接在数据库中运行的SQL语句
- SQL SERVER在存储过程中连接其他数据库
- 在Eclipse中实现Jdbc连接SQL Server2005数据库
- myeclipse连接sybase数据库后,在SQL Results中乱码
- 在web.config文件中连接sql 数据库
- 在Eclipse中连接SQL Server 2005数据库
- sql server数据库在c#中连接不成功处理办法
- 在sql server 中创建链接服务器连接mysql数据库
- 在JAVA中如何连接SQL Server数据库
- 在Eclipse中连接SQL Server 2008数据库
- 动网论坛入侵之插件篇
- MAX骨骼动画插件终于写完了。
- (zz )CS Rank in USA.
- 大学新生人生目标的失落及重新确立(转帖)
- 你在远方,找不到自己的方向
- 在IE中直接连接SQL数据库
- 访问加密过的Access之怪现象
- 不要相信生意人
- [收藏]成年人必看的5个故事
- XML Web Service 数据交换
- 流水张
- 开发花絮:一个DataList的ItemCommand事件意外
- 开发人员的一种新思维模式
- 用 EJB3.0 简化 EJB 开发