(高分求解答,UP有分!) ADO读取dbf文件的问题!!

Set Conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;"
DBPath = "SourceDB=" & Server.MapPath( "test.dbf" )
Conn.Open Driver & DBPath

Sql="Select * From test" '这地方的表名难道不是文件名??,用VFP打开显示的就是这个名字啊
Set Rs=Conn.Execute(Sql)

会报错:
Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e37'
[Microsoft][ODBC Visual FoxPro Driver]File 'test.dbf' does not exist.

---------------------------------------------------------------

贴一段我以前写的高考录取中的部分代码

 1   
 2DatabaseDBFPath="e:/InetPub/testonline/high-education/2002_DATABASE_DBF/2002_Matriculate.dbf"   
 3Set MagicFs = Server.CreateObject("scripting.FileSystemObject")   
 4Set MagicFile = MagicFs.GetFile(DatabaseDBFPath)   
 5updatedate=MagicFile.datelastmodified   
 6set MagicFs=nothing   
 7set MagicFile=nothing   
 8Set conn = Server.CreateObject("ADODB.Connection")   
 9Driver = "Driver={Microsoft Visual FoxPro Driver};"   
10SourceType = "SourceType=DBF;"   
11DatabasePath=Server.MapPath("DBF")   
12DatabasePath="e:/InetPub/testonline/high-education/2002_DATABASE_DBF"   
13DBPath = "SourceDB=" & DatabasePath   
14conn.Open Driver & SourceType & DBPath   
15Set rs = Server.CreateObject("ADODB.Recordset")   
16'打开DBF文件,参数二为Connection对象   
17query="select count(*) from 2002_Matriculate"   
18rs.Open query, conn, 2, 2   

---------------------------------------------------------------

用绝对路径吧!
---------------------------------------------------------------

DatabasePath=Server.MapPath("DBF")
DatabasePath="e:/InetPub/testonline/high-education/2002_DATABASE_DBF"
DBPath = "SourceDB=" & DatabasePath
为什么DatabasePath赋两次值
不能用相对路径吗?
---------------------------------------------------------------

Jaron(唐伯虎点蚊香) ( ) 信誉:312
在用DBF数据库时,把 dbf 存在的目录名称当成了一个数据库名,
而文件夹里的每个文件作为一个表.

这是队的!
---------------------------------------------------------------

Set Conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;"
DBPath = "SourceDB=" & Server.MapPath( "./test.dbf" )
Conn.Open Driver & DBPath
---------------------------------------------------------------

up
---------------------------------------------------------------

up~

Published At
Categories with Web编程
comments powered by Disqus