当前位置: 首页 > 图文教程 > 网络编程 > ASP > access中链接表的问题

ASP
asp 实现对SQL注入危险字符进行重编码处理的函数
asp下实现对HTML代码进行转换的函数
asp 验证用户名是否包含有非常字符的函数
ASP通用分页样式函数代码
asp 生成任意英文+数字位数长度的随机码函数
asp 取得中文句子头一个字的大写拼音字母的函数
asp实现计算两个时间内的工作日的函数
asp实现过滤关键字的函数
asp实现限制搜索的关键字的函数
asp动态include文件,方便多模板的实现
推荐的用Asp实现屏蔽IP地址访问的代码
XDOWNPAGE ASP版本 分页类
飞云防CC攻击ASP程序代码插件
定期自动运行ASP程式的代码
ASP下Cookie操作的详细讲解
再发几个ASP不错的函数
比较不错的asp模板引终极讲解(WEB开发之ASP模式)
ip138之asp小偷程序代码
在VBScript中实现-函数/方法名作为参数传入另一个函数
asp实现批量插入表单中的数据到数据库的方法

ASP 中的 access中链接表的问题


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 160 ::
收藏到网摘: n/a

一个使用asp和mdb的站点,某个mdb中使用了链接表,链接到当前目录的另一个mdb中的表,这样可以达到数据共享。
faq-it.org/delphi_win_sdk/问题来了,当将网站发布到网站的时候,因为网上空间路径和我本机不同,所以链接表失败,网页当然也不能打开。
我觉得解决办法有:
一种,在本机上创建与网上空间完全相同的目录结构。但这很麻烦,特别是经常要换网站的话。
一种,如何让链接表使用相对路径,就是链接到当前目录下的那个mdb文件?(对了,access很弱智,链接表记录的是绝对路径)。
还一种,如何通过编程(asp 或者本地vba)来实现对链接表的链接的修改?(又对了,access还是弱智,更新链接表我只能使用手工更新,一定要找到那个路径下的mdb才行!可本地路径和网上不一样呀)
谁能告诉我如何实现上面的后两种方法?
---------------------------------------------------------------
以下是我自己在用的adox代码,只为了证明我说的access有此功能(说句不好听的:这关access p事啊?这是ado模型该解决的问题。而且你也提错地方了,提到asp那一块更合适),做access编程的都应该看得懂,如果你看不懂我也只能说遗憾了。
Public Function NewLinkedExternalTableMdb()
Dim strTargetDB() As String
Dim strProviderString() As String
Dim strSourceTbl() As String
Dim strLinkTblName() As String
Dim catDB As ADOX.Catalog
Dim tblLink As ADOX.Table
Dim tmpLink As ADOX.Table
Dim i As Integer
Dim j As Integer
Set catDB = New ADOX.Catalog
catDB.ActiveConnection = CurrentProject.Connection
i = catDB.Tables.Count
ReDim strTargetDB(i)
ReDim strProviderString(i)
ReDim strSourceTbl(i)
ReDim strLinkTblName(i)
i = 1
For Each tmpLink In catDB.Tables
If tmpLink.Properties("Jet OLEDB:Create Link") Then
If Trim(tmpLink.Properties("Jet OLEDB:Remote Table Name")) <> "" Then
strLinkTblName(i) = tmpLink.Name
strTargetDB(i) = tmpLink.Properties("Jet OLEDB:Link Datasource")
strProviderString(i) = tmpLink.Properties("Jet OLEDB:Link Provider String")
strSourceTbl(i) = tmpLink.Properties("Jet OLEDB:Remote Table Name")
Do While InStr(1, strTargetDB(i), "/") <> 0
strTargetDB(i) = Mid(strTargetDB(i), InStr(1, strTargetDB(i), "/") + 1, Len(strTargetDB(i)))
Loop
strTargetDB(i) = CurrentProject.Path & "/" & strTargetDB(i)
i = i + 1
End If
End If
Next
j = i - 1
For i = 1 To j
catDB.Tables.Delete strLinkTblName(i)
Set tblLink = New ADOX.Table
With tblLink
.Name = strLinkTblName(i)
Set .ParentCatalog = catDB
.Properties("Jet OLEDB:Create Link") = True
.Properties("Jet OLEDB:Link Datasource") = strTargetDB(i)
.Properties("Jet OLEDB:Link Provider String") = strProviderString(i)
.Properties("Jet OLEDB:Remote Table Name") = strSourceTbl(i)
End With
catDB.Tables.Append tblLink
Set tblLink = Nothing
Next
Set catDB = Nothing
End Function